Web Manual
Web Manual
To edit the XHTML program: In Windows, Type the program in notepad , name it as… filename.HTML
TO RUN THE PROGRAM: In Windows, open Internet Explorer …Select the HTML file ..in URL field to
Run the document.
IN FEDORA …Open Browser…In FILES Option Select ..Open File Select …File System
Select…VAR Select…WWW Select…HTML Then select HTML file to be Run.
OR
Program 1: Create a XHTML document to display a table, an image, hyperlink and different
lists available in XHTML.
p,table,li,
{
font-family: "lucida calligraphy", arial, 'sans serif';
margin-left: 10pt;
}
p { word-spacing:5px; }
body { background-color:rgb(200,255,205); }
p,li,td { font-size:75%;}
td { padding:0.5cm; }
th {
text-align:center;
font-size:85%;
}
table
{
border-style:outset;
background-color: rgb(100,255,105);
}
li {list-style-type:lower-roman;}
span
{
color:blue;
background-color:pink;
font-size:29pt;
font-style:italic;
font-weight:bold;
}
Program 2: Develop and demonstrate, using JavaScript script, a XHTML document that collects
the USN ( the valid format is: A digit from 1 to 4 followed by two upper-case characters followed by
two digits followed by two upper-case characters followed by three digits; no embedded spaces
allowed) of the user. Event handler must be included for the form element that collects this
information to validate the input. Messages in the alert windows must be produced when errors are
detected.
function iscorrect(elem1)
{
usnexp=/[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/
if(elem1.value.length==0)
{
alert("US Number is empty");
elem1.focus();
return false;
}
else if(!elem1.value.match(usnexp))
{
alert("USN Number should be in DAADDAADDD format");
elem1.focus();
return false;
}
alert("USN Number IS CORRECT");
return true;
}
</script></head>
<body>
<form onsubmit='return validator()'>
Enter your USN. in DAADDAADDD format : <input type='text' id='req1'/>
<input type='submit' value='Check Field' />
</form>
</body>
</html>
Program 3: Write a JavaScript to design a simple calculator to perform the following
operations: sum, product, difference and quotient.
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head> <title>Calculator</title>
<style>
.button { background-color: #4CAF50; /* Green */
border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none;
display: inline-block; font-size: 16px; }
</style>
<script src="calculator.js" type="text/javascript"></script>
</head>
<body>
<h1>My calculator</h1>
<table border="1" cellpadding="5" cellspacing="5" width="600">
<tr align="center">
<td>First number</td> <td>Second Number</td> <td>Result</td>
</tr>
<tr align="center">
<td><input name="number1" type="text" size=10 id='num1'/> </td> <td>
<input name="number2" type="text" size=10 id='num2'/> </td> <td>
<input type="text" id='result' onclick="this.blur()" > </td>
</tr>
<tr> <td colspan="3">
<button class="button" onclick="showresult('1')">+ </button>
<button class="button" onclick="showresult('2')">- </button>
<button class="button" onclick="showresult('3')">* </button>
<button class="button" onclick="showresult('4')">/ </button>
<button class="button" value="CLEAR ALL" onclick="cls()"/>CLEAR</td> </td>
</tr>
</table>
</body>
</html>
calculatotr.js
function cls()
{ num1.value="";
num2.value="";
result.value=""; }
function showresult(choise)
{ var n1=parseFloat(document.getElementById('num1').value);
var n2=parseFloat(document.getElementById('num2').value);
var r;
var c=choise;
switch(c) { case '1': r=n1+n2; break;
case '2': r=n1-n2; break;
case '3': r=n1*n2; break;
case '4': r=n1/n2; break;
default: break; }
document.getElementById('result').value=r; }
Program 4: Write a JavaScript that calculates the squares and cubes of the numbers from 0 to
10 and outputs HTML text that displays the resulting values in an HTML table format.
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head> <title>Program 4 0-10 Square and Cubes </title>
<script>
document.write ( "<center><table> <tr> <th>Number</th> <th>Square</th> <th>Cube</th>
</tr>" )
for(var n=0; n<=10; n++)
{ document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>" )
}
document.write( "</table></center>" )
</script>
<style> table { color: #333; /* Lighten up font color */
font-family: Helvetica, Arial, sans-serif; /* Nicer font */
width: 640px; border-collapse: collapse; border-spacing: 0; }
td, th { border: 1px; solid #CCC; height: 30px; } /* Make cells a bit taller */
th {background: #2676af; /* Light grey background */
font-weight: bold; /* Make sure they're bold */ }
td {background: #FAFAFA; /* Lighter grey background */
text-align: center; /* Center our text */ }
</style>
</head>
</html>
Program 5: Write a JavaScript code that displays text “TEXT-GR OWING” with increasing
font size in the interval of 100ms in RED COLOR, when the font size reaches 50pt it displays
“TEXT-SHRINKING” in BLUE color.Then the font size decreases to 5pt.
Showhide.js
Function flipimage()
{ dom=document.getElementById(“apple”).style;
if(dom.visibility==”visible”)
dom.visibility=”hidden”;
else
dom.visibility=”visible”;
}
Program 7: Develop and demonstrate, using Java script , a XHTML document that contains
three short paragraphs of text, stacked on top of each other, with only enough of each showing so
that the mouse cursor can be placed over some part of them. When the cursor is placed over the
exposed part of any paragraph, it should rise to the top to become completely visible. When a
paragraph is moved from the top stacking position, it should return to its original position.
<body bgcolor=”teal”>
<h1> Program to demonstrate usage of stacking of paragraph</h1>
<div class=”ls1”
id=”layer1” onmouseover=”stack(‘layer1’)”>
<b>… FIRST PARAGRAPH..DOWN ONE(Pink)…………..</b>
</div>
<div class=”ls2”
id=”layer2” onmouseover=”stack(‘layer2’)”>
<b>… SECOND PARA..LAST BUT ONE(Blue)…………..</b>
</div>
<div class=”ls3”
id=”layer3” onmouseover=”stack(‘layer3’)”>
<b>… THIRD PARA..(Gray)…....</b>
</div>
<div class=”ls4”
id=”layer4” onmouseover=”stack(‘layer4’)”>
<b>… TOP LAYER..FOURTH PARAGRAPH…(Yellow)…...</b>
</div>
</body>
</html>
External Style Sheet ….// stacking.css :Type and save stacking.css in
HTML folder.
.ls1 { border:solid-thick-block;
padding:1in;
width:500px;
background-color:pink;
position:absolute;
top:100px;
left:200px;
}
.ls2 { border:solid-thick-block;
padding:1in;
width:500px;
background-color:blue;
position:absolute;
top:150px;
left:250px;
}
.ls3 { border:solid-thick-block;
padding:1in;
width:500px;
background-color:gray;
position:absolute;
top:200px;
left:300px;
}
.ls4 { border:solid-thick-block;
padding:1in;
width:500px;
background-color:yellow;
position:absolute;
top:250px;
left:350px;
}
Program 8: Write a Perl program to accept the User Name and display a greeting message
randomly chosen from a list of 4 greeting messages.
Localhost:CGI-BIN# httpd
To Run perl program, open browser and type URL as: http://localhost/cgi-bin/greeting.pl
#!/usr/bin/perl
use CGI ':standard';
@msg = ("Welcome","Have a nice","Good Morning","Good Day");
$range = 4;
$random_number = int(rand($range));
if(param)
{
print header();
print start_html(-title=>"User Name",-bgcolor=>"Pink",-
text=>"blue");
$cmd=param("name");
print b("Hello $cmd,$msg[$random_number]"),br();
print start_form();
print submit(-value=>"Back");
print end_form();
print end_html();
}
else
{
print header();
print start_html(-title=>"Enter user name",-
bgcolor=>"yellow",-text=>"blue");
print start_form(),textfield(-name=>"name",-value=>" "),
submit(-name=>"submit",-value=>"Submit"),reset();
print end_form();
print end_html();
}
Program 9: Write a Perl program to insert name and age information entered by the user into a
table created using MySQL and to display the current contents of this table.
IDENTIFIED BY ‘cool’;
#! /usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Result of the insert operation
</TITLE></HEAD>";
use CGI ':standard';
use DBI;
$dbh=DBI->connect("DBI:mysql:muz","apache","cool");
$name=param("name");
$age=param("age");
$qh=$dbh->prepare("insert into stud values('$name','$age')");
$qh->execute();
$qh=$dbh->prepare("Select * from stud");
$qh->execute();
print "<table border size=1><tr><th>Name</th><th>Age</th></tr>";
while ( ($name,$age)=$qh->fetchrow())
{
print "<tr><td>$name</td><td>$age</td></tr>";
}
print "</table>";
$qh->finish();
$dbh->disconnect();
print"</HTML>";
Type html Program in, HTML Folder. And run it on the browser.
<html>
<body>
<h1> Enter Information :</h1>
<form action="http://localhost/cgi-bin/10.pl">
Name : <input type="text" name="name"> <br>
Age :<input type="text" name="age"> <br>
<input type="submit" value="SUBMIT">
<input type="reset" value="RESET">
</form>
</html>