Practical
Practical
i)
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Navigation</title>
</head>
<body>
<h1>Navigation to Another Page</h1>
<a href="page2.html">Go to Page 2</a>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page 2</title>
</head>
<body>
<h1>Welcome to Page 2</h1>
<p>This is the second page linked from the main page.</p>
<a href="index.html">Go Back to Main Page</a>
</body>
</html>
<section id="about">
<h2>About Us</h2>
<p>XYZ College provides quality education.</p>
</section>
<section id="courses">
<h2>Courses Offered</h2>
<p>Science, Arts, Commerce.</p>
</section>
<section id="contact">
<h2>Contact Us</h2>
<p>Email: [email protected]</p>
</section>
</body>
</html>
2) simple calc
<!DOCTYPE html>
<html>
<head>
<title>Simple Calculator</title>
<script>
function calculate() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var operator = document.getElementById('operator').value;
var result;
if (operator === '+') {
result = num1 + num2;
} else if (operator === '-') {
result = num1 - num2;
} else if (operator === '*') {
result = num1 * num2;
} else if (operator === '/') {
result = num2 !== 0 ? num1 / num2 : 'Error: Division by zero';
} else if (operator === '%') {
result = num1 % num2;
}
css:
p{
color: #34495e;
}
DHTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Form</title>
<style>
body { font-family: Arial, sans-serif; margin: 50px; }
.form-container { width: 300px; margin: 0 auto; }
label, input { display: block; width: 100%; margin-bottom: 10px; }
.error { color: red; font-size: 12px; }
.input-error { border: 2px solid red; background-color: #ffe6e6; }
.success-message { color: green; font-size: 16px; font-weight: bold; text-align: center;
display: none; }
input[type="submit"] {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
input[type="submit"]:disabled { background-color: #ccc; }
</style>
</head>
<body>
<div class="form-container">
<h2>Simple Form</h2>
<label for="occupation">Occupation:</label>
<input type="text" id="occupation" oninput="validateForm()">
<div id="occupationError" class="error"></div>
<script>
function validateForm() {
let isValid = true;
function submitForm() {
document.getElementById("successMessage").style.display = "block";
document.querySelector("form").reset(); // Reset form after submission
document.getElementById("submitBtn").disabled = true; // Disable the submit button again
return false; // Prevent actual form submission to keep it simple
}
</script>
</body>
</html>
7)xml
<books>
<book>
<title>Learn Java</title>
<author>John Doe</author>
<year>2020</year>
</book>
<book>
<title>Web Development Basics</title>
<author>Jane Smith</author>
<year>2022</year>
</book>
</books>
Xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="year" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
xsl
<xsl:template match="/books">
<html>
<head><title>Book List</title></head>
<body>
<h1>Book List</h1>
<ul>
<xsl:for-each select="book">
<li>
<strong><xsl:value-of select="title"/></strong><br/>
Author: <xsl:value-of select="author"/><br/>
Year: <xsl:value-of select="year"/>
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>