KEMBAR78
Webtech Programs | PDF | Software | Computing
0% found this document useful (0 votes)
23 views30 pages

Webtech Programs

The document contains multiple HTML snippets demonstrating various web functionalities including email validation, a digital clock, a simple calculator, and a hit counter. It also showcases the use of dropdown lists, sorting numbers and strings, mouse over events, and employee payslip calculations. Each section includes JavaScript code to implement the respective feature.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views30 pages

Webtech Programs

The document contains multiple HTML snippets demonstrating various web functionalities including email validation, a digital clock, a simple calculator, and a hit counter. It also showcases the use of dropdown lists, sorting numbers and strings, mouse over events, and employee payslip calculations. Each section includes JavaScript code to implement the respective feature.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

EMAIL VALIDATION

<html><head>
<title>Check Email Address</title>
<script language="javascript">
function checkEmail(inputvalue){
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
if(pattern.test(inputvalue)){
alert("Valid Email");
}else{
alert("Invalid Email id please enter correct format");
}
}
</script>
</head><body>
<form name="signupform">
<h1> Email Validation </h1>
<br>
<br>
Input your email: <input name="email" type="text" >
<input type="submit" value="Check"
onClick="checkEmail(document.signupform.email.value)">
</form></body></html>
DIGITAL CLOCK
<html>
<br>
<br>
<br>
<head>
<title>Digital Clock</title>
</head><body >
<form >
<script language="javascript">
function f()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var sec=Digital.getSeconds()
document.write("DIGITAL CLOCK <br>")
document.write(hours+":"+minutes+":"+sec)
setTimeout('location.href = location.href',1000);
}
window.onload=f
</script>
</form></body></html>
SIMPLE CALCULATOR
<html>
<head>
<title>simple calculator</title>
</head>
<body>
<script language ="javascript">
function add()
{
var a = parseInt(form1.text1.value);
var b = parseInt(form1.text2.value);
form1.text3.value=a+b;
}
function sub()
{
var a = parseInt(form1.text1.value);
var b = parseInt(form1.text2.value);
form1.text3.value=a-b;
}
function mul()
{
var a = parseInt(form1.text1.value);
var b = parseInt(form1.text2.value);
form1.text3.value=a*b;
}
function div()
{
var a = parseInt(form1.text1.value);
var b = parseInt(form1.text2.value);
form1.text3.value=a/b;
}
</script>
<form name = form1>
<H2 align =center> SIMPLE CALCULATOR</H2>
<table align ="center">
<tr>
<td>
Enter value for A
</td>
<td>
<input type = text name = text1>
</td>
</tr>
<tr>
<td>
Enter value for B
</td>
<td><input type = text name = text2>
</td>
</tr>
<tr>
<td>
<input type = button value ="Addition" onclick=add()>
<input type = button value ="Subtraction" onclick=sub()></td>
<td>
<input type = button value ="Multiplication" onclick=mul()>
<input type = button value ="Division" onclick=div()>
</td>
</tr>
<tr>
<td>
Result
</td>
<td>
<input type = text name = text3>
</td>
</tr>
</table>
</form>
</body>
</html>
USING DROP DOWN LIST BOX
<html><head>
<title>dropdownlist</title>
</head><body>
<form >
<h1> Using Drop Down List box </h1>
<br><br>
Major Dishes <SELECT NAME="txt1" multiple =true>
<OPTION>Dosa
<OPTION>Idli
<OPTION>Upma
<OPTION>Puttu
<OPTION>Uttapam
<OPTION>Pongal</SELECT>
Stocks Available <SELECT NAME="txt2" multiple =true>
<OPTION>10
<OPTION>20
<OPTION>25
<OPTION>10
<OPTION>20
<OPTION>30
</SELECT>
Soft Drinks Available <SELECT NAME="txt3" >
<OPTION>Appy Fizz
<OPTION>Slice
<OPTION>Sprite
<OPTION>Frooti
<OPTION>Coca-cola
<OPTION>Maaza
</SELECT>
</form></body></html>
Squares, Roots, Cubes and Complements of Integers
between 1 and 100
<HTML>
<HEAD>
<TITLE> squares, roots, cubes and complements of integers between 1 and 100. </TITLE>
</HEAD>
<BODY>
<form>
<h1>Squares, Roots, Cubes and Complements of Integers between 1 and 100. </h1>
<script language ="javascript">
{
document.write("<table border =1 ><tr><td>Square
Root</td><td>Squares</td><td>Cubes</td><td>Binary</td><td>Complements</td></tr>");
for(i=1;i<=100;i++)
{
document.write("<tr><td> "+Math.sqrt(i) + "</td><td> "+i*i +"</td><td>"+
i*i*i+"</td><td>"+ i.toString(2)+"</td><td>"+ ~i+"</td></tr>");
}
}
</script>
</form>
</BODY>
</HTML>
SCROLL MESSAGE ON WINDOWS STATUS BAR
<html>
<script language="Javascript">
myMsg = "Welcome to Apollo Arts and Science College "
i=0
function scrollMsg() {
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i=0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
</script>
<h1> Scroll Message on Windows Status Bar</h1>
</html>
USING FRAMES
<html>
<head>
<title>Using Frames </title>
</head>
<frameset cols =25%,70% border =1>
<frame src ="frame.html" >
<frame src ="" width = 100 height = 300 name ="sample">
</frame>
</frameset>
</html>
frame.html
<html>
<br>
<br>
<br>
<br>
<form name = f1>
<a href ="yahoo.html" target = "sample">Yahoo</a>
<a href ="vista.html" target = "sample">ltavista</a>
<a href ="seek.html" target = "sample">Infoseek</a>
</form>
</html>
Yahoo.html
<HTML>
<BODY bgcolor ="pink">
<br>
<br>
<h1>WELCOME TO YAHOO WEBSEARCH
</BODY>
</HTML>
Vista.html
<HTML>
<BODY bgcolor ="blue">
<br>
<br>
<h1>WELCOME TO VISTA WEBSEARCH
</BODY>
</HTML>
Seek.html
<HTML>
<BODY bgcolor ="red">
<br>
<br>
<h1>WELCOME TO YAHOO WEBSEARCH
</BODY>
</HTML>
HIT COUNTER
<html><head>
<title>Hit Counter</title><script type="text/javascript" language="javascript">
now = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)
hitCt = parseInt(cookieVal("pageHit"))
hitCt++
lastVisit = cookieVal("pageVisit")
if (lastVisit == 0) {
lastVisit = ""
}
document.cookie = "pageHit="+hitCt+";expires=" + expireDate.toGMTString()
document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i=0; i<thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1]
}
}
return 0
}
</script></head><body><h2>
<script type="text/javascript" language="javascript">
document.write("You have Visited this Page " + hitCt + " times.")
if (lastVisit != "") {
document.write("<br />Your last Visit was " + lastVisit)
}
</script></h2></body></html>
SORTING NUMBERS AND STRINGS
<html>
<h1 align =center> Sorting Numbers and Strings</h1>
<head>
<title>
Sorting Numbers and Strings
</title>

<script type="text/javascript">

var fruits = ["Banana", "Orange", "Apple", "Mango"];


document.writeln("Sorting Strings:" +fruits.sort() +"<br />");
var n = ["4", "7", "9", "1"];
document.writeln("Sorting Numbers:"+n.sort());
</script>
</head>
<body>
<form></form>
</body>
</html>
ON MOUSE OVER EVENT
<html>
<head>
<title>
On Mouse over event</title>
<script language="javascript">
function imageinit()
{ img1On=new Image();
img1Off=new Image();
img1On.src="Garden.jpg";
img1Off.src="Dock.jpg";
}
function imageSwitchOn(imagename)
{
imageOn=eval(imagename+"On.src");
document[imagename].src=imageOn;
}
function imageSwitchOff(imagename)
{
imageOff=eval(imagename+"Off.src");
document[imagename].src=imageOff;
}
</script></head>
<body onLoad="imageinit()">
<center><h1>Image...</h1><br>
<h3><i>Place your mouse pointer on the picture</i></h3>
<a onMouseOver="imageSwitchOn('img1')" onMouseOut="imageSwitchOff('img1')">
<img src="star1.jpg" height=200 width=200 alt="space" name="img1"></a>
</center></body></html>
<Html>
<Head><Title>Changing Image</Title><Script>
function imageinit()
{
img1on=new Image();
img1off=new Image();
img1switch=new Image();

img1on.src="background.jpg";
img1off.src="Creek.jpg";
img1switch.src="Dock.jpg";
}
function imageSwitch1(imagename)
{
image=eval(imagename+"on.src");
document[imagename].src=image;
}
function imageSwitch2(imagename)
{
image=eval(imagename+"off.src");
document[imagename].src=image;
}
function imageSwitch3(imagename)
{
image=eval(imagename+"switch.src");
document[imagename].src=image;
}
</script>
</head>
<body onLoad="imageinit()">
<center>
<H1>Image...</H1>
<br>
<H3><i>Click the Button to View the Image...</i></H3>
<img src="Garden.jpg" height=200 width=200 alt="space" name="img1">
<br><br><br>
<input type="button" value="Butterfly" onClick="imageSwitch1('img1')">
<input type="button" value="Parrots" onClick="imageSwitch2('img1')">
<input type="button" value="Flowers" onClick="imageSwitch3('img1')">
</center>
</body>
</html>
EMPLOYEE PAYSLIP
<html>

<head>

<title> employee payship</title>

</head>

<body>

<script language="javascript">

function cal()

var a=parseInt(form1.text3.value);

var b=a*4/100;

var c=a*5/100;

var d=a+b+c;

form1.text4.value=b;

form1.text5.value=c;

form1.text6.value=d;

</script>

<form name=form1>

<h2 align=center>employeepayship</h2>

<table align="center">

<tr>

<td>

employee name:

</td>
<td>

<input type=text name=text>

</td>

</tr>

<tr>

<td>

employee number

</td><td><input type=text name=text2>

</td>

</tr>

<tr>

<td>

Salary</td>

<td>

<input type=text name=text3>

</td>

</tr>

<tr>

<td>pf</td>

<td>

<input type=text name=text4>

</td>

</tr>

<td>da</td>

<td>
<input type=text name=text5>

</td>

</tr>

<tr>

<td>netsalary</td>

<td>

<input type=text name=text6>

</td>

</tr>

<tr>

<td>

<input type=button value="calculation" onClick=cal()>

</td>

</tr>

</table>

</form>

</body>

</html>

You might also like