intpr
intpr
-- Question 1: -->
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<script>
function validateForm() {
const name = document.forms["regForm"]["name"].value;
const email = document.forms["regForm"]["email"].value;
const password = document.forms["regForm"]["password"].value;
const phone = document.forms["regForm"]["phone"].value;
if (!name || !email || !password || !phone) {
alert("All fields are required!");
return false;
}
if ([email protected](email)) {
alert("Invalid email format!");
return false;
}
if (password.length < 6) {
alert("Password must be at least 6 characters long!");
return false;
}
return true;
}
</script>
</head>
<body>
<form name="regForm" onsubmit="return validateForm()">
<label>Name:</label><input type="text" name="name"><br>
<label>Email:</label><input type="email" name="email"><br>
<label>Password:</label><input type="password" name="password"><br>
<label>Phone:</label><input type="tel" name="phone"><br>
<label>Gender:</label>
<select name="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select><br>
<button type="submit">Register</button>
</form>
</body>
</html>
<?php
$colors = ["Red", "Blue", "Green", "Yellow", "Pink"];
rsort($colors);
foreach ($colors as $color) {
echo $color . "\n";
}
?>
<!-- ......................adress.xml...........................
-->
<!-- ......................address.dtd...........................
-->
<!DOCTYPE address [
<!ELEMENT address (name, company, phoneNumber)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT phoneNumber (#PCDATA)>
]>
<address>
<name>Jane Smith</name>
<company>ABC Inc</company>
<phoneNumber>9876543210</phoneNumber>
</address>
<?php
$employees = ["Alice" => 25, "Bob" => 30, "Charlie" => 28, "David" => 35, "Eve" =>
22];
foreach ($employees as $name => $age) {
echo "$name: $age years old \n" ;
}
?>
<!-- ......................form.html...........................
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
</head>
<body>
<form action="process.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
<!-- ......................process.php...........................
-->
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve the username and password from the POST request
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Marks Table</title>
</head>
<body>
<h2>Student Marks</h2>
<table border="1" cellspacing="5" cellpadding="5">
<tr>
<th rowspan="2">Name</th>
<th colspan="2">Marks</th>
</tr>
<tr>
<th>Math</th>
<th>Science</th>
</tr>
<tr>
<td>John</td>
<td>85</td>
<td>90</td>
</tr>
<tr>
<td>Emma</td>
<td>78</td>
<td>88</td>
</tr>
<tr>
<td>Michael</td>
<td>92</td>
<td>84</td>
</tr>
<tr>
<td>Sophia</td>
<td>89</td>
<td>91</td>
</tr>
<tr>
<td>David</td>
<td>76</td>
<td>79</td>
</tr>
</table>
</body>
</html>
<script>
function appendValue(value) {
document.getElementById('result').value += value;
}
function calculateResult() {
try {
document.getElementById('result').value =
eval(document.getElementById('result').value);
} catch {
document.getElementById('result').value = 'Error';
}
}
</script>
</body>
</html>
/* styles.css */
<!DOCTYPE html>
<html>
<head>
<script>
function factorial(num) {
let result = 1;
for (let i = 1; i <= num; i++) result *= i;
return result;
}
</script>
</head>
<body>
<button onclick="alert('Factorial: ' + factorial(5))">Inline JS</button>
<script>
function checkEvenOdd(num) {
alert(num % 2 === 0 ? "Even" : "Odd");
}
</script>
<button onclick="checkEvenOdd(4)">Internal JS</button>
<script src="script.js"></script>
<button onclick="checkPrime(7)">External JS</button>
</body>
</html>
/* script.js */
function checkPrime(num) {
if (num < 2) return alert("Not Prime");
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return alert("Not Prime");
}
alert("Prime");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Selectors</title>
<style>
/* Global Selector */
* {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Class Selector */
.highlight {
color: white;
background-color: blue;
padding: 10px;
border-radius: 5px;
}
/* ID Selector */
#main-heading {
color: green;
text-align: center;
margin-top: 20px;
font-size: 24px;
}
</style>
</head>
<body>
<!-- Applying ID Selector -->
<h1 id="main-heading">CSS Selectors Example</h1>
<!DOCTYPE html>
<html>
<body>
<script>
function convert(degree) {
var x;
if (degree == "C") {
x = document.getElementById("c").value * 9 / 5 + 32;
document.getElementById("f").value = Math.round(x);
} else {
x = (document.getElementById("f").value -32) * 5 / 9;
document.getElementById("c").value = Math.round(x);
}
}
</script>
</body>
</html>
checkLeapYear(year);
function checkMultiple(number) {
if (number % 3 === 0 && number % 7 === 0) {
console.log(`${number} is a multiple of both 3 and 7.`);
} else if (number % 3 === 0) {
console.log(`${number} is a multiple of 3.`);
} else if (number % 7 === 0) {
console.log(`${number} is a multiple of 7.`);
} else {
console.log(`${number} is not a multiple of 3 or 7.`);
}
}