Professional Documents
Culture Documents
Q: Write a program for Regular expression where the text box should accept only
numbers and other text box should accept only characters.
A: You can achieve this using JavaScript. Here's a code snippet:
javascript
// Accept only numbers in the first text box
document.getElementById("numericTextBox").addEventListener("input", function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
<script>
$(document).ready(function(){
$("#myButton").click(function(){
$("#demo").text("jQuery is awesome!");
});
});
</script>
</body>
</html>
Q: Explain with an example on jQuery getters and setters.
A: jQuery getters and setters are used to get and set element properties. Here's an
example:
javascript
// Getter
var text = $("#demo").text();
console.log("Text: " + text);
// Setter
$("#demo").text("New Text");
Q: Write a program to manipulate text box, radio button, text, and buttons using jQuery.
A: You can manipulate various elements using jQuery. Here's an example for
manipulating a text box and a button:
html
<input type="text" id="myInput">
<button id="myButton">Click Me</button>
<script>
$(document).ready(function(){
$("#myButton").click(function(){
var inputValue = $("#myInput").val();
alert("Input Value: " + inputValue);
});
});
</script>
Q: Write a code for slide up(), toggle, slide down, fade in, fade out.
A: Here's an example showing slideUp(), toggle(), slideDown(), fadeIn(), and fadeOut()
in jQuery:
javascript
$(document).ready(function(){
$("#slideUpButton").click(function(){
$("#myDiv").slideUp();
});
$("#toggleButton").click(function(){
$("#myDiv").toggle();
});
$("#slideDownButton").click(function(){
$("#myDiv").slideDown();
});
$("#fadeInButton").click(function(){
$("#myDiv").fadeIn();
});
$("#fadeOutButton").click(function(){
$("#myDiv").fadeOut();
});
});
Chapter 4: Bootstrap
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "Employee ID: " . $row["employee_id"] . ", Name: " . $row["employee_name"];
}
} else {
echo "No employees found.";
}
Q: Create a form for username and password and filter the details using regular
expression.
A: Here's an HTML form for username and password with PHP validation using regular
expressions:
html
<form method="post" action="process.php">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="Submit">
</form>
In your PHP script (process.php), you can use regular expressions to validate and filter
the input.
Chapter 6: Web Development Framework