Sdc Lab Internal
Sdc Lab Internal
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header><h1>Welcome to Shopping Cart</h1></header>
<nav>
<a href="index.html">Home</a> |
<a href="login.html">Login</a> |
<a href="registration.html">Register</a> |
<a href="cart.html">Cart</a>
</nav>
<main>
<h2>Best Deals on Books</h2>
<p>Save up to 90% on selected books!</p>
</main>
<footer>© 2024 MyShop</footer>
</body>
</html>
login.html
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Login</h2>
<form>
Username: <input type="text" name="username"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
registration.html
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Register</h2>
<form>
Name: <input type="text" name="name"><br><br>
Email: <input type="email" name="email"><br><br>
Password: <input type="password" name="pass"><br><br>
Phone: <input type="text" name="phone"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
cart.html
<!DOCTYPE html>
<html>
<head>
<title>Cart</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Your Cart</h2>
<table border="1">
<tr><th>Book</th><th>Price</th><th>Quantity</th><th>Total</th></tr>
<tr><td>HTML Basics</td><td>300</td><td>2</td><td>600</td></tr>
<tr><td>JavaScript</td><td>400</td><td>1</td><td>400</td></tr>
</table>
</body>
</html>
body {
font-family: Arial;
margin: 20px;
}
nav {
background-color: #e6e6e6;
display: flex;
justify-content: space-around;
font-weight: bold;
}
main {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
background-color: #f0f0f0;
padding: 10px;
}
footer {
background-color: #333;
color: white;
text-align: center;
}
Exp-02: Make the above web application responsive web application using Bootstrap framework.
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<header class="bg-primary text-white text-center p-3">
<h1>Welcome to Shopping Cart</h1>
</header>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">Login</h2>
<form class="w-50 mx-auto">
<div class="mb-3">
<label class="form-label">Username</label>
<input type="text" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="password" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">Register</h2>
<form class="w-50 mx-auto">
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">Email</label>
<input type="email" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="password" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">Phone</label>
<input type="text" class="form-control">
</div>
<button type="submit" class="btn btn-success">Register</button>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cart</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">Your Cart</h2>
<table class="table table-bordered table-striped">
<thead class="table-dark">
<tr>
<th>Book</th><th>Price</th><th>Qty</th><th>Total</th>
</tr>
</thead>
<tbody>
<tr><td>HTML Basics</td><td>300</td><td>2</td><td>600</td></tr>
<tr><td>JavaScript</td><td>400</td><td>1</td><td>400</td></tr>
</tbody>
</table>
</div>
</body>
</html>
Exp-03: Use JavaScript for client-side validation of the pages implemented in Experiment 1
(registration and login).
HTML: registration.html
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<script src="validate.js"></script> <!-- JS file -->
</head>
<body>
<h2>Register</h2>
<form name="regForm" onsubmit="return validateForm()">
Name: <input type="text" name="username"><br><br>
Email: <input type="text" name="email"><br><br>
Password: <input type="password" name="password"><br><br>
Phone: <input type="text" name="phone"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
JavaScript: validate.js
function validateForm() {
let uname = document.regForm.username.value;
let email = document.regForm.email.value;
let pass = document.regForm.password.value;
let phone = document.regForm.phone.value;
if (pass.length < 6) {
alert("Password must be at least 6 characters.");
return false;
}
if (phone.length != 10 || isNaN(phone)) {
alert("Please enter a valid 10-digit phone number.");
return false;
}
alert("Registration Successful!");
return true;
}
HTML: login.html
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<script>
function checkLogin() {
let uname = document.loginForm.username.value;
let pass = document.loginForm.password.value;
alert("Login Successful!");
return true;
}
</script>
</head>
<body>
<h2>Login</h2>
<form name="loginForm" onsubmit="return checkLogin()">
Username: <input type="text" name="username"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Exp-04: Develop a Java standalone application that connects with MySQL database and performs
CRUD (Create, Read, Update, Delete) operations.
import java.sql.*;
import java.util.*;
String query = "INSERT INTO student VALUES(" + id + ", '" + name + "', '" +
address + "')";
stmt.executeUpdate(query);
System.out.println("Inserted successfully.");
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
2. DisplayData.java
import java.sql.*;
System.out.println("ID\tName\tAddress");
while (rs.next()) {
System.out.println(rs.getInt("id") + "\t" + rs.getString("name") + "\t" +
rs.getString("address"));
}
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
3. UpdateData.java
import java.sql.*;
import java.util.*;
String query = "UPDATE student SET name='" + name + "', address='" + address +
"' WHERE id=" + id;
stmt.executeUpdate(query);
System.out.println("Updated successfully.");
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
4. DeleteData.java
import java.sql.*;
import java.util.*;
System.out.println("Deleted successfully.");
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
Exp-05: Create an XML for a bookstore. Validate the same using both DTD and XSD.
</xs:schema>
Exp-06: Create a custom server using the http module and explore other modules of Node.js like os,
path, and events.
● <body>: Contains all visible content of the web page such as text, images, links, forms, etc.
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
Example:
<title>My Web Page</title>
10. i) How does the <form> tag work, and what attributes does it use?
The <form> tag is used to collect user input. It wraps form controls like text fields, checkboxes, radio
buttons, and submit buttons.
Important attributes:
● action – URL where form data is sent
● method – HTTP method (GET or POST)
● enctype – Encoding type for data (multipart/form-data for file upload)
● target – Where to display the response (_self, _blank, etc.)
Example:
<form action="/submit" method="post">
<input type="text" name="name">
<input type="submit" value="Submit">
</form>
ii) What are the new HTML5 form elements, and how are they useful?
HTML5 introduced new input types and form elements to enhance usability and reduce the need for
JavaScript validation.
New input types:
● email – Validates email format
● url – Validates URL format
● date, month, week – Date selectors
● range – Slider input
● tel – Phone number input
● number – Numeric input with spinner
● color – Color picker
Example:
<input type="email" required>
<input type="range" min="0" max="100">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
</datalist>
<input list="browsers">