Web Lab Programs
Web Lab Programs
Web Lab Programs
<!DOCTYPE html>
<html>
<head>
<title>My First Web page</title>
<!--<style>
body{
font-family:Arial,sans-serif;
line-heigth:1.6;
margin:0;
padding:20px;
}
/style>-->
<link href="web.css" rel="stylesheet">
</head>
<body>
<b> <u><marquee>Basic HTML tags </marquee></u></b>
<h1>Headings</h1>
<h2>Paragraphs</h2>
<h3>Horizontal line</h3>
<h4>Black Quote</h4>
<h5>Pre tag</h5>
<h6>Moving Text</h6>
<hr>
<p> In HTML and CSS, syntax is the order in which elements appear or are
written, meaning the grammar and spelling of the language.
Syntax rules are in place to ensure the languages are always written in a way
that can be read or interpreted by a computer.</p>
<hr>
<p>Here is quote from W3 schools</p>
<blackquote>W3Schools is a freemium educational website for learning coding
online. Initially released in 1998, it derives its name from the World Wide
Web but is not affiliated with the W3 Consortium.<br> W3Schools offers courses
covering many aspects of web development. W3Schools also publishes free HTML templates.
<hr>
<b><u><p>A self-closing tag </p></u></b>
<pre>This is a tag that combines an opening and closing tag into one, and is
used to indicate that there is no content between the tags. Self-closing tags are also known as
empty tags.</pre>
</body>
</html>
OUTPUT-
2.Develop the HTML page named as “Table.html” to display your class time table. a) Provide the
title as Time Table with table header and table footer, row-span and col-span etc. b) Provide
various colour options to the cells (Highlight the lab hours and elective hours with different
colours.) c) Provide colour options for rows.
<!DOCTYPE html>
<html lang="en">
<style>
table,th,td{
border:1px solid black;
height:50px;
background-color:"blue";
}
</style>
<head>
<title>Time Table</title>
</head>
<body>
<table>
<!DOCTYPE html>
<html>
<head>
<title>CSS SELECTOR</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<h2>A J INSTITUTE OF ENGINEERING AND TECHNOLOGY</h2>
<img src="aj.jfif">
<h3>Department of Computer Science And Engineering</h3>
<hr>
<p>A J Institute of Engineering & Technology is promoted by Laxmi Memorial
Education Trust which was registered in the year 1991 in the memory of Late Laxmi Shetty,
mother of Dr. A. J. Shetty, who is the President and Managing Director of the Trust.
font-family:georgia,serif;
text-align:center;
}
h2{
text-align:center;
font-family:georgia,serif;
background-color:yellow;
}
h3{
}
span{
background-color:#FFF8DC;
font-family:fantasy;
}
marquee{
font-family:fantasy;
}
a{
font-size:18px;
font-family:
}
OUTPUT-
4.Develop HTML page named as “registration.html” having variety of HTML input elements with
background colors, table for alignment & provide font colors & size using CSS styles.
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form>
<h2>STUDENT REGISTRATION FORM</h2>
<label>NAME:</label>
<select id="branch">
<option>Computer Science And Engineering</option>
<option>Information Science And Engineering</option>
<option>Electronics And Communication Engineering</option>
<option>Artificial Intelligence And Machine Learning
</select>
<br>
<br>
<button>Submit</button>
</form>
</body>
</html>
h2{
Text-align:center;
text-decoration:underline;
font-family:Sans-serif;
font-weight:20px;
}
body{
text-align:center;
font-family:fantasy;
margin-top:200px;
}
button:hover{
width:100px;
height:50x;
background-color:yellow;
}
label{
text-decoration:bold;
}
form{
border:2px solid black;
background-color:aqua;
margin:2rem auto;
width:500px;
height:300px;
}
OUTPUT-
5.Develop HTML page named as “newpaper.html” having variety of HTML semantic elements
with background colors, text-colors & size for figure, table, aside, section, article, header,
footer… etc.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Daily Chronicle</title>
<style>
body {
font-family: 'Georgia', serif;
line-height: 1.6;
color: #333;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f4f4f4;
}
header {
background-color: #1a1a1a;
color: #fff;
padding: 20px;
text-align: center;
}
header h1 {
margin: 0;
font-size: 2.5em;
}
nav {
background-color: #333;
color: #fff;
padding: 10px;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
}
nav ul li {
margin: 0 10px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
main {
display: flex;
margin-top: 20px;
}
section {
flex: 2;
margin-right: 20px;
}
article {
background-color: #fff;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
article h2 {
color: #1a1a1a;
font-size: 1.8em;
}
aside {
flex: 1;
background-color: #e6e6e6;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
figure {
margin: 0;
text-align: center;
}
figure img {
max-width: 100%;
height: auto;
}
figcaption {
font-style: italic;
color: #666;
font-size: 0.9em;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
footer {
background-color: #1a1a1a;
color: #fff;
text-align: center;
padding: 10px;
margin-top: 20px;
}
</style>
</head>
<body>
<header>
<h1>The Daily Chronicle</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Politics</a></li>
<li><a href="#">Technology</a></li>
<li><a href="#">Sports</a></li>
<li><a href="#">Entertainment</a></li>
</ul>
</nav>
<main>
<section>
<article>
<h2>Breaking News: Major Technological Breakthrough</h2>
<p>Scientists have announced a groundbreaking discovery in the field of quantum
computing, potentially revolutionizing the tech industry.</p>
<figure>
<img
src="https://www.cnet.com/a/img/resize/c7cb26e927bebaa784fb55a01e71d7fecb15d2e3/hub/20
19/06/26/3f76e99d-8055-46f3-8f27-558ee276b665/20180405-ibm-q-quantum-computer-02.jpg?
auto=webp&fit=crop&height=675&width=1200" alt="Quantum Computer">
<figcaption>A state-of-the-art quantum computer at the research
facility</figcaption>
</figure>
</article>
<article>
<h2>Local Sports Team Wins Championship</h2>
<p>In a thrilling match, our local team secured victory in the national championship,
bringing pride to our city.</p>
<table>
<tr>
<th>Team</th>
<th>Score</th>
</tr>
<tr>
<td>Local Heroes</td>
<td>3</td>
</tr>
<tr>
<td>Visiting Challengers</td>
<td>2</td>
</tr>
</table>
</article>
</section>
<aside>
<h3>Weather Update</h3>
<p>Expect sunny skies with a high of 75°F (24°C) today.</p>
<h3>Upcoming Events</h3>
<ul>
<li>City Festival - This Weekend</li>
<li>Tech Conference - Next Month</li>
<li>Charity Run - In Two Weeks</li>
</ul>
</aside>
</main>
<footer>
<p>© 2024 The Daily Chronicle. All rights reserved.</p>
</footer>
</body>
</html>
OUTPUT-
6.Apply HTML, CSS and JavaScript to design a simple calculator to perform the following
operations: sum, product, difference, remainder, quotient, power, square-root and square.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Calculator</title>
<style>
*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(45deg, green, black);
min-height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
}
form {
width: 300px;
border: 2px solid black;
padding: 15px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
}
input[name="display"] {
background-color: blue;
border: none;
color: white;
width: 100%;
padding: 20px;
font-size: 24px;
text-align: right;
border-radius: 5px;
margin-bottom: 10px;
box-sizing: border-box;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
.buttons input[type="button"] {
background-color: #333;
color: white;
padding: 15px;
font-size: 18px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.buttons input[type="button"]:hover {
background-color: #555;
}
.operator:hover {
background-color: darkorange;
}
.clear {
background-color: red;
grid-column: span 2;
}
.clear:hover {
background-color: darkred;
}
.equal {
background-color: green;
grid-column: span 2;
}
.equal:hover {
background-color: darkgreen;
}
</style>
</head>
<body>
<form name="calculator">
<input type="text" name="display" disabled title="display" />
<div class="buttons">
<input type="button" value="7" onclick="calculator.display.value += '7'">
<input type="button" value="8" onclick="calculator.display.value += '8'">
<input type="button" value="9" onclick="calculator.display.value += '9'">
<input type="button" value="/" onclick="calculator.display.value += '/'" class="operator">
</html>
OUTPUT-
7.Develop JavaScript program (with HTML/CSS) for: a) Converting JSON text to JavaScript
Object b) Convert JSON results into a date c) Converting From JSON To CSV and CSV to
JSON d) Create hash from string using crypto.createHash() method
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>JSON/CSV Converter and Hash Generator</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<style>
body{
font-family:Arial,sans-serif;
line-height:1.6;
margin:0;
padding:20px;
background-color:#f4f4f4;
}
.container{
max-width:800px;
margin:auto;
background:white;
padding:20px;
border-radius:5px;
box-shadow:0 0 10px rgba(0,0,0,0.1);
}
h1{
color:#333;
}
textarea{
width:100%;
height:100px;
margin-bottom:10px;
}
button{
background-color:#4CAF50;
color:white;
padding:10px 15px;
border:none;
border-radius:4px;
cursor:pointer;
margin-right:10px;
}
button:hover{
background-color:#45a049;
}
#result{
margin-top:20px;
padding:10px;
background-color:#e7e7e7;
border-radius:4px;
}
</style>
</head>
<body>
<div class="container">
<h1>JSON/CSV Converter and Hash Generator</h1>
<script>
function convertJsonToObject(){
try{
const jsonInput=document.getElementById('jsonInput').value;
const jsObject=JSON.parse(jsonInput);
document.getElementById('result').innerText='Converted
Object:'+JSON.stringify(jsObject,null,2);
}
catch(error){
document.getElementById('result').innerText='Error:'+error.message;
}
}
function convertJsonToDate(){
try{
const jsonInput=document.getElementById('jsonDateInput').value;
const jsObject=JSON.PARSE(jsonInput);
const date=new Date(jsObject.date);
document.getElementById('result').innerText='Converted
Date:'+date.toString();
}catch(error){
document.getElementById('result').innerText='Error:'+error.message;
}
}
function convertJsonToCsv(){
try{
const
jsonInput=document.getElementById('dataInput').value;
const jsObject=JSON.parse(jsonInput);
const headers=Object.keys(jsObject[0]);
const csvRows=[headers.join(','),
...jsObject.map(row=>headers.map(fieldName=>JSON.stringify(row[fieldName])).join(','))];
const csvString=csvRows.join('\n');
document.getElementById('result').innerText='Converted CSV:\n'+csvString;
}catch(error){
document.getElementById('result').innerText='Error:'+error.message;
}
}
function convertCsvToJson(){
try{
const
csvInput=document.getElementById('dataInput').value;
const lines=csvInput.split('\n');
const headers=lines[0].split(',');
const jsonArray=lines.slices(1).map(line=>{
const values=line.split(',');
return headers.reduce((obj,header,index)=>{
obj[header]=values[index];
return obj;
},{});
});
document.getElementById('result').innerText='Converted
JSON:\n'+JSON.stringify(jsobArray,null,2);
}catch(error){
document.getElementById('result').innerText='Error:'+error.message;
}
}
function createHash(){
try{
const input=document.getElementById('hashInput').value;
const hash=CryptoJS.SHA256(input);
document.getElementById('result').innerText='Generated
Hash(SHA256):'+hash;
}catch(error){
document.getElementById('result').innerText='Error:'+error.message;
}
}
</script>
</body>
</html>
OUTPUT-
8.a. Develop a PHP program (with HTML/CSS) to keep track of the number of visitors visiting
the web page and to display this count of visitors, with relevant headings. b. Develop a PHP
program (with HTML/CSS) to sort the student records which are stored in the database using
selection sort.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Visitor Counter</title>
<style>
body {
background-color: #f4f4f4;
.container {
max-width: 600px; margin: auto; background: white; padding: 20px; border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
h1 {
color: #333;
text-align: center;
}
.counter {
</style>
</head>
<body>
<div class="container">
<div class="counter">
<?php
$counterFile = 'visitor_count.txt';
if (file_exists($counterFile)) {
$count = (int)file_get_contents($counterFile);
} else {
$count = 0;
$count++;
?>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
.container {
max-width: 800px; margin: auto; background: white; padding: 20px; border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
text-align: center;
table {
width: 100%;
th, td {
padding: 10px;
th {
background-color: #f2f2f2;
</style>
</head>
<body>
<div class="container">
<h1>Student Records</h1>
<?php
// Database connection details
$host = 'localhost';
$dbname = 'student_records';
$username = 'root';
$password = '';
try {
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$students = $stmt->fetchAll(PDO::FETCH_ASSOC);
$min_idx = $i;
$min_idx = $j;
}
if ($min_idx != $i) {
$temp = $arr[$i];
$arr[$i] = $arr[$min_idx];
$arr[$min_idx] = $temp;
echo "</table>";
} catch(PDOException $e) {
?>
</div>
</body>
</html>
OUTPUT-
9.Develop jQuery script (with HTML/CSS) for: a. Appends the content at the end of the existing
paragraph and list. b. Change the state of the element with CSS style using animate() method c.
Change the color of any div that is animated.
<!DOCTYPE html>
<head>
<title>jQuery Append,Animate ad Color change Demo</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body{
font-family:Arial,sans-serif;
line-height:1.6;
margin:0;
padding:20px;
background-color:#f4f4f4;
}
.container{
max-width:800px;
margin:auto;
background:white;
padding:20px;
border-radius:5px;
box-shadow:0 0 10px rgba(0,0,0,0.1);
}
h1,h2{
color:#333;
}
.box{
width:100px;
height:100px;
background-color:#3498db;
margin:L20px 0;
}
button{
padding:10px 15px;
background-color:#2ecc71;
color:white;
order:none;
border-radius:5px;
cursor:pointer;
margin-right:10px;
}
button:hover{
background-color:#27ae60;
}
</style>
</head>
<body>
<div class="container">
<h1>jQuery Demonstration</h1>
<h2>a.Append Content</h2>
<p id="existingParagraph">This is an existing paragraph</p>
<ul id="existingList">
<li>Existing item 1</li>
<li> Existing item 2</li>
</ul>
<button id="appendButton">Append Content</button>
<h2>b.Animate Element</h2>
<div id="animateBox" class="box"></div>
<button id="animateButton">Animate Box</button>
<!DOCTYPE html>
<head>
<title>jQuery Append,Animate ad Color change Demo</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body{
font-family:Arial,sans-serif;
line-height:1.6;
margin:0;
padding:20px;
background-color:#f4f4f4;
}
.container{
max-width:800px;
margin:auto;
background:white;
padding:20px;
border-radius:5px;
box-shadow:0 0 10px rgba(0,0,0,0.1);
}
h1,h2{
color:#333;
}
.box{
width:100px;
height:100px;
background-color:#3498db;
margin:L20px 0;
}
button{
padding:10px 15px;
background-color:#2ecc71;
color:white;
order:none;
border-radius:5px;
cursor:pointer;
margin-right:10px;
}
button:hover{
background-color:#27ae60;
}
</style>
</head>
<body>
<div class="container">
<h1>jQuery Demonstration</h1>
<h2>a.Append Content</h2>
<p id="existingParagraph">This is an existing paragraph</p>
<ul id="existingList">
<li>Existing item 1</li>
<li> Existing item 2</li>
</ul>
<button id="appendButton">Append Content</button>
<h2>b.Animate Element</h2>
<div id="animateBox" class="box"></div>
<button id="animateButton">Animate Box</button>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ajax Demo program</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body{
font-family:Arial,sans-serif;
line-height:1.6;
margin:0;
padding:20px;
background-color:#f4f4f4;
}
.container{
max-width:800px;
margin:auto;
background:white;
padding:20px;
border-radius:5px;
box-shadow:0 0 10px rgba(0,0,0,0.1);
}
h1{
color:#333;
}
h2{
color:#666;
}
button{
background-color:#4cAF50;
border:none;
color:white;
padding:10px 20px;
text-align:center;
text-decoration:none;
display:inline-block;
font-size:16px;
margin:4px 2px;
cursor:pointer;
border-radius:4px;
}
pre{
background-color:#f8f8f8;
border:1px solid #ddd;
border-radius:4px;
padding:10px;
white-space:pre-wrap;
word-wrap:break-word;
}
</style>
</head>
<body>
<div class= "container">
<h1>Ajax Demo Program</h1>
<h2>Ajax-like operation without jQuery</h2>
<button onclick="operationWithoutjQuery()">Perform Operation(without
jQuery)</button>
<pre id="result-a"></pre>
<h2>b.Ajax-like operation with jQuery</h2>
<button onclick="operationWithjQuery()">Perform Operation(with
jQuery)</button>
<pre id="result-b"></pre>
<h2>c.jQuery-like getJSON() method</h2>
<button onclick="getJSONOperation()">get JSON</button>
<pre id="result-c"></pre>
<h2>d.jQuery parseJSON() method</h2>
<button onclick="parseJSONExample()">Parse JSON</button>
<pre id="result-d"></pre>
</div>
<script>
//simulated data
const simulatedData={
text:"This is a sample text from a simulated server response",
json:{
name:"John Doe",
age:30,
city:"New York"
}
};
//a
function operationWithoutjQuery(){
setTimeout(function(){
document.getElementById("result-a").textContent=simulatedData.text;
},500);
}
//b
function operationWithjQuery(){
$.Deferred(function(deferred){
setTimeout(function(){
deferred.resolve(simulatedData.text);
},500);
}).done(function(result){
$("#result-b").text(result);
});
}
//c
function getJSONOperation(){
$.Deferred(function(deferred){
setTimeout(function(){
deferred.resolve(simulatedData.json);
},500);
}).done(function(result){
$("#result-c").text(JSON.stringify(result,null,2));
});
}
//d
function parseJSONExample(){
var jsonString=JSON.stringify(simulatedData.json);
var jsonObject=$.parseJSON(jsonString);
$("#result-d").text(JSON.stringify(jsonObject,null,2));
}
</script>
</body>
</html>
OUTPUT-