MCSL-016, LAB MANUAL (JAVA SCRIPT)
SECTION 3
SECTION 3
INTERNET CONCEPTS AND WEB DESIGN, INTERNET CONCEPTS & WEB DESIGNING, INDIRA GANDHI NATIONAL OPEN UNIVERSITY, LAB MANUAL, (HTML, ADVANCED HTML, JAVA SCRIPT, VBScript (V.B. Script), Dreamweaver, (INDIRA GANDHI NATIONAL OPEN UNIVERSITY NOTES, IGNOU NOTES, IGNOU ASSIGNMENTS, IGNOU FIRST SYMESTER, IGNOU QUESTION PAPERS); IGNOU PROSPECTUR, IGNOU SYLLABUS, IGNOU MCA NOTES; MCA IGNOU - FIRST YEAR; MCA - IGNOU - SYM 1 :
ACCORDING TO YEAR 2011 (JULY - JANUARY SESSION - SYLLABUS)
NOTE : These are our / my personal Notes - I suggest you (students) to please follow your own syllabus and/ or books as these are my/ our personal and modified notes - for my personal use only, Thanks.
=========================================================
1.3 Java ScriptSession
14.How would you write any statement using only one write or writeln()
command?<html><head></head><script language="JavaScript">function
newpages(){document.writeln("Hi ");document.write("Welcome To My
Website");}</script><body><form name="form1" method="post" action="">
<p><input type="submit" name="Submit" value="Enter" onClick="newpages
()"></p></form></body></html>
5.Embed java script in html document asking user name and then
printing Hello<user Name>
<html><head></head><script language="JavaScript">function newpages
(txt){document.writeln("Hello " + txt);}</script><body><form
name="form1" method="post" action=""><p>Enter User Name<input
name="t1" type="text" id="t1"></p><p><input type="submit"
name="Submit" value="Enter"onClick="newpages
(form1.t1.value)"></p></form></body></html>
6.Create a dialogue box with “Welcome to my website” message.
<html><head></head><script language="JavaScript">alert("Welcome to my
website");</script><body></body></html>
=================================
Session 2
1.Evaluate the expressiona.
Ans. 7+5b. “7”+”5”c. 7*5d. 7/5e.7%5<html><head></head><script
language="JavaScript">function Calculate(choice){var result;switch
(choice)
{case 1:result=7+5; break;case 2:result="7" + "5"; break;case
3:result=7*5; break;case 4:result=7/5; break;case 5:result=7%5;
break;}document.writeln(result);}</script><body><form name="form1"
method="post" action=""> <p>Evaluate The
Expression</p><p><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate(1)">7+5</label><br><label><input
type="radio" name="RadioGroup1" value="radio"onClick="Calculate
(2)">"7" + "5"</label>
<br><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate(3)">7*5</label><br><label><input
type="radio" name="RadioGroup1" value="radio"onClick="Calculate
(4)">7/5</label><br><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate
(5)">7%5</label><br></p></form></body></html>
2. Write the segment of script that would ask the user if he wants a
greetingmessage and if he does, display a gif file called Welcome. gif
and display“Welcome to Netscape navigator!” in the document window
following the gif.<html><head></head><script
language="JavaScript">function messages(){input_box=confirm("Do You
Want a Greeting");if(input_box==true){window.open
("welcome.jpg");window.document.write("Welcome to Netscape navigator!"
);}else{alert("You Have Selected No");}}</script><body><form
name="form1" method="post" action=""><input type="submit"
name="Submit" value="Submit" onClick="messages
()"></form></body></html>
3.Write the object definition for an object called car with four
properties model,make, year and price.
<html><head><script language="JavaScript">var car=new
Object;car.model="Marcides
Benz";car.year=2008;car.make="DX";car.price=4500000;</script></head><s
cript language="JavaScript">function printdet(){document.write(" Model
: " + car.model);document.write(", Make : " +
car.make);document.write(", Year : " + car.year);document.write(",
Price : " +car.price);}</script><body><form name="form1" method="post"
action=""><input type="submit" name="Submit" value="Print Details"
onClick="printdet()"></form></body></html>
1.Write a program to display a multiplication
table.<html><head></head><script language="JavaScript">function
multable(){var num=prompt("Enter The No");var i;for(i=0;i<=10;i++)
{document.write(num + " * " + i + " = " + num*i +"<br>");}}
</script><body><form name="form1" method="post" action=""><input
type="submit" name="Submit" value="Print Details"onClick="multable
()"></form></body></html>
2.Write code to create a scrolling text.<html><head></head><script
language="JavaScript">function movetext(){if(txt.style.posLeft<720)
{txt.style.posLeft=txt.style.posLeft+2;window.setTimeout("movetext
()",5);}else{txt.style.posLeft=0;window.setTimeout("movetext()",5);}}
</script><body onLoad="movetext()"><form name="form1" method="post"
action=""><div id="txt"
style="position:relative;top:3;left0"><h2>Scrolling
Text</h2></div></form></body></html>
Session 42. Write a program to change color of text
randomly<html><head><script language="JavaScript">var colors=new
Array(6);colors[0]="#0000FF"; colors[1]="#FF0000"; colors[2]
="#006600";colors[3]="#FFCC00";colors[4]="#00FFFF"; colors[5]
="#000000";var i=1;</script></head><script
language="JavaScript">function changecolor(){ document.fgColor=colors
[i];i++;if(i>5)i=0;setTimeout("changecolor()",100);}</script><body
onLoad="changecolor()"><div align="center"><strong><font
size="7">Hello </font></strong> </div></body></html>
3.Create a web page using two image files, which switch b/w on another
as themouse pointer moves over the image. Use on mouse over and on
mouse out eventhandler.<html><head><script
language="JavaScript">function MM_swapImgRestore() {var
i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;}function MM_preloadImages() {var d=document; if
(d.images){ if(!d.MM_p) d.MM_p=new Array();var
i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;i
++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a
[i];}}}function MM_findObj(n, d) {var p,i,x; if(!d) d=document; if
((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames
[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all)
x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for
(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers
[i].document);if(!x && d.getElementById) x=d.getElementById(n); return
x;}function MM_swapImage() {var i,j=0,x,a=MM_swapImage.arguments;
document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)if
((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}}</script></head><body
onLoad="MM_preloadImages('welcome.JPG')"><a href="#"
onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('Image1','','welcome.JPG',1)"><imgsrc="Img1.jpg" name="Image1"
width="261" height="195" border="0"></a></body></html>
Session 52 . Use the date function get & set date to prompt the user
for an integer b/w 1-31 &return day of the week it
represents.<html><head></head><script language="JavaScript">function
setdate(){var dt=new Date();dt=new Date
(form1.y.value,form1.m.value,form1.d.value);form1.gt.value=dt.getDate
() + "/" + dt.getMonth() + "/" +dt.getFullYear();}</script><body><form
name="form1" method="post" action=""><p>Day <input name="d"
type="text" id="d" size="3">Month <input name="m" type="text" id="m"
size="3">Year <input name="y" type="text" id="y" size="4"><input
type="button" name="Button" value="SetDate" onClick="setdate
()"></p><p> Date <input name="gt" type="text" id="gt">
</p></form></body></html>
2.Display time and print the message accordingly e.g Good morning in
morning etc.<html><head><script language="JavaScript">var dt=new Date
();document.write("Good Morning The Time Is : " + dt.getHours() +":" +
dt.getMinutes() + ":" + dt.getSeconds
());</script></head><body></body></html>
Session 61.Using java script create a digital
clock.<html><head></head><script language="JavaScript">function
getTimes(){var dt=new Date();form1.t.value= dt.getHours() + ":" +
dt.getMinutes() + ":" + dt.getSeconds();window.setTimeout("getTimes
()",1000);}</script><body onLoad="getTimes()"><form name="form1"
method="post" action=""><input name="t" type="text"
id="t"></form></body></html>
Session 71.Using java script create a
calculator.<html><head></head><script language="JavaScript">function
calc(ch){if(ch=="=")form1.t.value= eval(form1.t.value);elseif
(ch=="C")form1.t.value= "";elseform1.t.value+=ch;}</script><body
onLoad="getTimes()"><form name="form1" method="post" action=""><input
name="t" type="text" id="t"><br><input type="button" name="Button"
value="7" onClick="calc('7')"><input type="button" name="Submit2"
value="8" onClick="calc('8')"><input type="button" name="Submit3"
value="9" onClick="calc('9')"> <input type="button" name="Submit4"
value="+" onClick="calc('+')"><br><input type="button" name="Submit5"
value="4" onClick="calc('4')"><input type="button" name="Submit6"
value="5" onClick="calc('5')"><input type="button" name="Submit7"
value="6" onClick="calc('6')"><input type="button" name="Submit8"
value="-" onClick="calc('-')"><br><input type="button" name="Submit9"
value="1" onClick="calc('1')"><input type="button" name="Submit10"
value="2" onClick="calc('2')"><input type="button" name="Submit11"
value="3" onClick="calc('3')"><input type="button" name="Submit12"
value="*" onClick="calc('*')"><br><input type="button" name="Submit13"
value="0" onClick="calc('0')"><input type="button" name="Submit14"
value="C" onClick="calc('C')"><input type="button" name="Submit15"
value="=" onClick="calc('=')"><br></form></body></html>
Session 81.Create a web page with a textbox and check for validation.
If empty displaymessage and set focus to it, if filled display thank
you.<html><head></head><script language="JavaScript">function check()
{if(form1.t.value==""){alert("Enter The Text");form1.t.focus();}else
{alert("Thank You");}}</script><body><form name="form1" method="post"
action="">Enter a Text<input name="t" type="text" id="t"><input
type="submit" name="Submit" value="Submit" onClick="check
()"></form></body></html>
Session 111. Create a program to generate a hit counter
<html><head></head><script language="JavaScript">var
counter;counter=0;function count(){counter++;alert("Counter : " +
counter);}</script><body><form name="form1" method="post"
action=""><div align="center"><input type="button" name="Button"
value="Hit Me" onClick="count()"></div></form></body></html>
2.Create a program to check email address provided by the user is
valid or invalid.<html><head></head><script
language="JavaScript">function check(){if(form1.t.value==""){alert
("Enter The Text");form1.t.focus();}else{var
email,a,d,diff,k,c;email=form1.t.value;a=email.indexOf
('@');d=email.indexOf('.');diff=parseInt(d)-parseInt(a);k=parseInt
(d)+1;c=email.charAt(k);if(a<1||diff<=1||c==""){alert("Invalid Email
ID");form1.t.focus();}}}</script><body><form name="form1"
method="post" action="">Enter Email ID <input name="t" type="text"
id="t"><input type="submit" name="Submit" value="Submit"
onClick="check()"></form></body></html>
Session 121.Write a program to scroll the text on status
bar.<html><head></head><html><head></head><script
language="JavaScript">var ar="Scrolling Text";var space="";var
i;i=1;function count(){var cont,k=0;cont="";while(k<=i){cont=cont + "
";k++;}status=cont +ar;i++;if(i>100)i=0;window.setTimeout("count
()",5);}</script><body onLoad="count
()"></body></html><body></body></html>
2. Write a program to create a small window in a main
window.<html><head><script language="JavaScript">window.open
("newwindow.html");</script></head><body></body></html>
Session 151.Use java script for authentication and verification of the
text boxes in the staticsite developed by the student in the html
exercise.<html><head></head><script language="JavaScript">function
check(){if(form1.t.value==""){alert("Enter The
Username");form1.t.focus();}else if(form1.t2.value==""){alert("Enter
The Password");form1.t2.focus();}else{if((form1.t.value!="")||
(form1.t2.value!=”")){alert("Invalid Username or Password");}}}
</script><body><form name="form1" method="post" action=""><p>User Name
<input name="t" type="text" id="t"> </p><p>Password <input name="t2"
type="password" id="t2"> </p><p> <input type="button" name="Button"
value="Button" onClick="check()"></p></form></body></html>
a.VB ScriptSession 11.Write a program to display the following on a
web pageHello <User Name><html><head></head><script
language="VBScript">sub newpages(txt)document.writeln("Hello " + txt)
end sub</script><body><form name="form1" method="post"
action=""><p>Enter User Name<input name="t1" type="text"
id="t1"></p><p><input type="submit" name="Submit"
value="Enter"onClick="newpages
(form1.t1.value)"></p></form></body></html>
2.Create a web page that display a message box with the
message“welcome to my web site”<html><head></head><script
language="VBScript">sub msgs()msgbox("Welcome To My Web Site")end
sub</script><body><form name="form1" method="post" action=""><p>
<input type="submit" name="Submit" value="Message"onClick="msgs()">
</p></form></body></html>
3.Write code to change color of text
randomly.<html><head></head><script language="VBScript">dim colors(5)
colors(0)="#0000FF"colors(1)="#FF0000"colors(2)="#006600"colors(3)
="#FFCC00"colors(4)="#00FFFF"colors(5)="#000000"dim ii=0sub
changecolor()msgbox("Welcome To My Web Site")document.fgColor=colors
(i)i=i+1if(i>5) theni=0end if window.setTimeout("changecolor()",100)
end sub</script><body onLoad="changecolor()"><div
align="center"><strong><font size="7">Hello </font></strong>
</div></body></html>
Session 21.Write a VB Script code that accepts the length, breadth and
height and display thearea of a rectangle.<html><head></head><script
language="VBScript">sub area()dim l,b,h,ar 40
l=form1.l.value b=form1.b.valueh=form1.h.valuear=l*b*hmsgbox("Area " &
ar)end sub</script><body onLoad="changecolor()"><form name="form1"
method="post" action="">Length <input name="l" type="text"
id="l">Breadth <input name="b" type="text" id="b">Height <input
name="h" type="text" id="h"><br><input type="button" name="Button"
value="Area" onClick="area()"></form></body></html>
2.Create a programme to generate a hit counter
<html><head></head><script language="VBScript">dim counter
counter=0sub count()counter=counter+1msgbox("Counter : " & counter)end
sub</script><body><form name="form1" method="post" action=""><div
align="center"><input type="button" name="Button" value="Hit Me"
onClick="count()"></div></form></body></html>
Session 31.Using vbscript create a calculator
<html><head></head><script language="VBScript">sub calc(ch)if(ch="=")
then form1.t.value= eval(form1.t.value)elseif(ch="C")
thenform1.t.value= ""elseform1.t.value=form1.t.value & chend if end if
end sub</script><body onLoad="getTimes()"><form name="form1"
method="post" action=""><input name="t" type="text" id="t"><br><input
type="button" name="Button" value="7" onClick="calc('7')"><input
type="button" name="Submit2" value="8" onClick="calc('8')"><input
type="button" name="Submit3" value="9" onClick="calc('9')"><input
type="button" name="Submit4" value="+" onClick="calc('+')"><br><input
type="button" name="Submit5" value="4" onClick="calc('4')"><input
type="button" name="Submit6" value="5" onClick="calc('5')"><input
type="button" name="Submit7" value="6" onClick="calc('6')"><input
type="button" name="Submit8" value="-" onClick="calc('-')"><br><input
type="button" name="Submit9" value="1" onClick="calc('1')"><input
type="button" name="Submit10" value="2" onClick="calc('2')"><input
type="button" name="Submit11" value="3" onClick="calc('3')"><input
type="button" name="Submit12" value="*" onClick="calc('*')"><br><input
type="button" name="Submit13" value="0" onClick="calc('0')"><input
type="button" name="Submit14" value="C" onClick="calc('C')"><input
type="button" name="Submit15" value="=" onClick="calc
('=')"><br></form></body></html>
Session 41.Create a programme to check for null or empty
string<html><head></head><script language="VBScript">sub check()if
(form1.t.value="")thenmsgbox("Enter The Text")form1.t.focus()
elsealert("Thank You")end if end sub</script><body><form name="form1"
method="post" action="">Enter a Text<input name="t" type="text"
id="t"><input type="submit" name="Submit" value="Submit"
onClick="check()"></form></body></html>
2.Create a form that has e-mail field. Now Write VB Script code for
Validation.<html><head></head><script language="VBScript">sub check()
if(form1.t.value="")thenalert("Enter The Text")form1.t.focus()elsedim
email,a,d,diff,k,cemail=form1.t.valuea=InStr(1,email,"@")d=InStr
(1,email,".")diff=d-ak=d+1c=Mid(email, k, 1)if(a<1 or diff<=1 or
c="")thenalert("Invalid Email ID")form1.t.focus()end if end if end
sub</script><body><form name="form1" method="post" action="">Enter
Email ID <input name="t" type="text" id="t"><input type="submit"
name="Submit" value="Submit" onClick="check()"></form></body></html>
Session 51.List Mouse and Key events in vbscriptMouse Events :
MouseOver, MouseOutKey Events : KeyUp,KeyDown,KeyRelease,
KeyPress2.How do you create random numbers in vbscript?Random No is
Generated byRndFunction
Session 61.Create a form in HTML containing the following files and
then perform thevalidation of each field using VBScript. Name-
textboxAddress-textboxDate Of Birth-Combo boxEmail-
textbox<html><head></head><script language="VBScript">sub check()if
(form1.n.value="")thenalert("Enter The Name")form1.n.focus()elseif
(form1.a.value="")thenalert("Enter The Address")form1.a.focus()elseif
(form1.y.value="")thenalert("Enter The Year")form1.y.focus()elseif
(form1.d.value="")thenalert("Select The Day")form1.d.focus()elseif
(form1.m.value="")thenalert("Select The Month")form1.m.focus()elseif
(form1.mail.value="")thendim
email,a,d,diff,k,cemail=form1.t.valuea=InStr(1,email,"@")d=InStr
(1,email,".")diff=d-ak=d+1c=Mid(email, k, 1)if(a<1 or diff<=1 or
c="")thenalert("Invalid Email ID")form1.t.focus()end if end if end
sub</script><body><form name="form1" method="post"
action=""><p>Name<input name="n" type="text" id="n"><br>Address<input
name="a" type="text" id="a"><br>Date Of Birth : Day<select name="d"
id="d"
><option>1</option><option>2</option><option>3</option><option>4</opti
on><option>5</option><option>6</option><option>7</option><option>8</op
tion><option>9</option><option>10</option>
<option>11</option><option>12</option><option>13</option><option>14</o
ption><option>15</option><option>16</option><option>17</option><option
>18</option><option>19</option><option>20</option>
<option>21</option><option>22</option><option>23</option><option>24</o
ption><option>25</option><option>26</option><option>27</option><option
>28</option><option>29</option><option>30</option><option>31</option><
/select>Month<select name="m"
id="m"><option>Jan</option><option>Feb</option><option>Mar</option><op
tion>Aprl</option><option>May</option><option>Jun</option><option>July
</option><option>Aug</option><option>Sep</option><option>Oct</option><
option>Nov</option><option>Dec</option></select>Year <input name="y"
type="text" id="y" size="6"><br>Email Id <input name="mail"
type="text" id="mail"><br> <input type="button" name="Button"
value="Button"onClick="check()"></form></body></html>
Session 8
1.Create a program the accepts the time from the system clock and
accordinglydisplays a Good morning, Good Afternoon and Good Evening
message to the user <html><head></head><script language="VBScript">sub
wish()dim hh=Datepart("h",Now)if h>=1 and h<=12 thenmsgbox("Good
Morning")elseif h>=13 and h<=18 thenmsgbox("Good Afternoon")
elsemsgbox("Good Evening")end if end sub</script><body onLoad="wish
()"></body></html>
Session 91.Write a programme that uses For next Looping Statements to
create a FibonacciSeries.<html><head></head><script
language="VBScript">sub fib()dim a,b,ca=1 b=1document.write("First 10
Fibonacci Series<br>")document.write(a & " " & b &
" ")for i=3 to 10c=cint(a)+cint(b)document.write(c &
" ")a=b b=cnextend sub</script><body onLoad="fib
()"></body></html>
2.Using Do While display the factorial of a
number.<html><head></head><script language="VBScript">sub fact(n)dim
f,if=1i=1do while(i<=cint(n))f=cint(f)*cint(i)i=i+1loopdocument.write
("<br>Factorial Of " & n & " is " & f)end sub</script><body><form
name="form1" method="post" action=""><input name="n" type="text"
id="n"><input name="Button" type="button" onClick="fact
(form1.n.value)"value="Factorial"></form></body></html>
Session 101.Write a Program that displays the multiplication of two
matrices.<html><head></head><script language="VBScript">sub matmul()
dim m1(3,3),m2(3,3),m3(3,3),count,i,jcount=0msgbox("Enter First
matrix")for i=0 to 2for j=0 to 2m1(i,j)=inputbox("")nextnextmsgbox
("Enter Seconf matrix")for i=0 to 2for j=0 to 2m2(i,j)=inputbox("")
next nextdocument.write("<br>Product of two Matrix<br>")for i=0 to
2for j=0 to 2for k=0 to 2m3(i,j)=cint(m3(i,j))+cint(m1(i,k))* cint(m2
(k,j))nextnextnextfor i=0 to 2for j=0 to 2document.write(" " & m1
(i,j))nextdocument.write("<br>")nextdocument.write("<br>+<br>")for i=0
to 2for j=0 to 2document.write(" " & m2(i,j))nextdocument.write
("<br>")nextdocument.write("<br>=<br>")for i=0 to 2for j=0 to
2document.write(" " & m3(i,j))nextdocument.write("<br>")nextend
sub</script><body onLoad="matmul()"></body>
3 . Write a program that accepts a number from the user and displays
its factorialonly if it is a prime number.<html><head></head><script
language="VBScript">sub ChkPrime(n)dim i,prime,k prime=truefor i=2 to
cint(n)/2if (n Mod i)=0 thenprime=falseend if nextif prime=true
thenfact(n)elsedocument.write("<br>The Number is Not Prime")end if end
subsub fact(n)dim f,if=1i=1do while(i<=cint(n))f=cint(f)*cint(i)i=i
+1loopdocument.write("<br>Factorial Of " & n & " is " & f)end
sub</script><body><form name="form1" method="post" action=""><input
name="n" type="text" id="n"><input name="Button" type="button"
onClick="ChkPrime
(form1.n.value)"value="factorial"></form></body></html>
DreamweaverSESSION 11.Design a home page of your TLC.<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Untitled Document</title><meta
http-equiv="Content-Type" content="text/html; charset=iso-8859-
1"></head><body><table width="100%" border="1" cellpadding="0"><tr><td
bgcolor="#ccc123"><div align="center"><strong><font
size="6">IGNOUPROGRAM STUDY
CENTER</font></strong></div></td></tr><tr><td bgcolor="#cccc12"><div
align="center"><strong><font size="6">WELCOMETO
</font></strong></div></td></tr><tr><td bgcolor="pink"><div
align="center"><strong><br><font size="4"><a
href="faculty_coord.html">FACULTIES ANDCOORDINATORS</a><br><a
href="theory_b_schedule.html">THEORY BATCH SCHEDULES</a> <br><a
href="prac_b_schedule.html">PRACTICAL BATCH SCHEDULES</a><br><a
href="sem_detail.html">SEMESTER WISE LIST OF STUDENTS</a> <br><a
href="assignment.html">ASSIGNMENT AND VIVA-VOCE</a> <br><a
href="ask_y_question.htm">ASK YOUR QUESTION</a> <br><a
href="mail.htm">MAIL US</a>
</font></strong><fontsize="4"></font></div></td></tr></table><p
align="center"><br></p></body></html>
2.Design a Home Page for a toy Company. The page has an image as th
background. Do some text attracting format.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Toy Page</title><meta http-
equiv="Content-Type" content="text/html; charset=iso-8859-
1"></head><body background="646.jpg"><table width="100%" border="0"
cellpadding="0"><tr><td><div align="center"><strong><font
color="#33FF00" size="7">Tom
ToysCenter</font></strong></div></td></tr><tr><td> </td></tr><tr>
<td align="left" valign="top"><table width="100%"
border="1"cellpadding="0"><tr><td width="27%"><table width="100%"
border="1" cellpadding="0"><tr><td><div align="center"><font
size="5"><strong><ahref="prof.htm">Profiles</a></strong></font></div><
/td></tr><tr><td><div align="center"><font
size="5"><strong><ahref="Toys.htm">Toys</a></strong></font></div></td>
</tr><tr><td><div align="center"><font
size="5"><strong><ahref="cont.htm">ContactUs</a></strong></font></div>
</td></tr></table></td><td width="73%" align="left" valign="top"><div
align="justify"><fontcolor="#FFFFFF" size="4">We are one of the
leading toy comapny in the city and have branchesin all major
districts thoughout kerala. Our toy Shope containsa vide variety of
collection of toys which taste the choice of your kids. toys posses a
high quality . the toys are normally importedfrom European and
American
Countries.</font></div></td></tr></table></td></tr><tr><td> </td>
</tr></table></body></html>
3.Insert a image in your page and give a zig zag motion to the image
in you page(using timeline).<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN"><html><head><title>Untitled
Document</title><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"><script language="JavaScript"
type="text/JavaScript"><!--function MM_timelinePlay(tmLnName, myID) {
//v1.2//Copyright 1997, 2000 Macromedia, Inc. All rights reserved.var
i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstT
ime=false;if (document.MM_Time == null) MM_initTimelines(); //if
*very* 1st timetmLn = document.MM_Time[tmLnName];if (myID == null) {
myID = ++tmLn.ID; firstTime=true;}//if new call, incr IDif (myID ==
tmLn.ID) { //if Im newestsetTimeout('MM_timelinePlay("'+tmLnName
+'",'+myID+')',tmLn.delay);fNew = ++tmLn.curFrame;for (i=0;
i<tmLn.length; i++) {sprite = tmLn[i];if (sprite.charAt(0) == 's') {if
(sprite.obj) {numKeyFr = sprite.keyFrames.length; firstKeyFr =
sprite.keyFrames[0];if (fNew >= firstKeyFr && fNew <=
sprite.keyFrames[numKeyFr-1]) {//inrangekeyFrm=1;for (j=0;
j<sprite.values.length; j++) {props = sprite.values[j];if (numKeyFr !=
props.length) {if (props.prop2 == null) sprite.obj[props.prop] =
props[fNew-firstKeyFr];else sprite.obj[props.prop2][props.prop] =
props[fNew-firstKeyFr];} else {while (keyFrm<numKeyFr &&
fNew>=sprite.keyFrames[keyFrm])keyFrm++;if (firstTime ||
fNew==sprite.keyFrames[keyFrm-1]) {if (props.prop2 == null)
sprite.obj[props.prop] = props[keyFrm-1];else sprite.obj[props.prop2]
[props.prop] = props[keyFrm-1];} } } } }} else if (sprite.charAt(0)
=='b' && fNew == sprite.frame) eval(sprite.value);if (fNew >
tmLn.lastFrame) tmLn.ID = 0;} }}function MM_initTimelines() {
//v4.0//MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights
reserved.var ns = navigator.appName == "Netscape";var ns4 = (ns &&
parseInt(navigator.appVersion) == 4);var ns5 = (ns && parseInt
(navigator.appVersion) > 4);document.MM_Time = new Array
(1);document.MM_Time[0] = new Array(3);document.MM_Time["Timeline1"] =
document.MM_Time[0];document.MM_Time[0].MM_Name =
"Timeline1";document.MM_Time[0].fps = 15;document.MM_Time[0][0] = new
String("sprite");document.MM_Time[0][0].slot = 1;if (ns4)
document.MM_Time[0][0].obj = document["Layer1"];else if (ns5)
document.MM_Time[0][0].obj = document.getElementById
("Layer1");elsedocument.MM_Time[0][0].obj = document.all ?
document.all["Layer1"] :null;document.MM_Time[0][0].keyFrames = new
Array(1, 15);document.MM_Time[0][0].values = new Array(2);if (ns5)
document.MM_Time[0][0].values[0] = new Array("21px", "24px",
"28px","31px", "35px", "38px", "42px", "45px", "48px", "52px", "55px",
"59px", "62px","66px", "69px");elsedocument.MM_Time[0][0].values[0] =
newArray
(21,24,28,31,35,38,42,45,48,52,55,59,62,66,69);document.MM_Time[0]
[0].values[0].prop = "left";if (ns5)document.MM_Time[0][0].values[1] =
new Array("16px", "21px", "25px","30px", "35px", "39px", "44px",
"48px", "53px", "58px", "62px", "67px", "72px","76px", "81px");else
document.MM_Time[0][0].values[1] = newArray
(16,21,25,30,35,39,44,48,53,58,62,67,72,76,81);document.MM_Time[0]
[0].values[1].prop = "top";if (!ns4) {document.MM_Time[0][0].values
[0].prop2 = "style";document.MM_Time[0][0].values[1].prop2 =
"style";}document.MM_Time[0][1] = new String
("sprite");document.MM_Time[0][1].slot = 1;if (ns4)document.MM_Time
[0][1].obj = document["Layer1"];else if (ns5)document.MM_Time[0]
[1].obj = document.getElementById("Layer1");elsedocument.MM_Time[0]
[1].obj = document.all ? document.all["Layer1"]
:null;document.MM_Time[0][1].keyFrames = new Array(16,
30);document.MM_Time[0][1].values = new Array(2);if (ns5)
document.MM_Time[0][1].values[0] = new Array("69px", "77px",
"85px","93px", "102px", "110px", "118px", "126px", "134px", "142px",
"150px","159px", "167px", "175px", "183px"); elsedocument.MM_Time[0]
[1].values[0] = newArray
(69,77,85,93,102,110,118,126,134,142,150,159,167,175,183);document.MM_
Time[0][1].values[0].prop = "left"; if (ns5)document.MM_Time[0]
[1].values[1] = new Array("81px", "77px", "72px","68px", "63px",
"59px", "54px", "50px", "45px", "41px", "36px", "32px", "27px","22px",
"18px");elsedocument.MM_Time[0][1].values[1] = newArray
(81,77,72,68,63,59,54,50,45,41,36,32,27,22,18);document.MM_Time[0]
[1].values[1].prop = "top";if (!ns4) {document.MM_Time[0][1].values
[0].prop2 = "style";document.MM_Time[0][1].values[1].prop2 =
"style";}document.MM_Time[0][2] = new String
("sprite");document.MM_Time[0][2].slot = 1;if (ns4)document.MM_Time
[0][2].obj = document["Layer1"];else if (ns5)document.MM_Time[0]
[2].obj = document.getElementById("Layer1");elsedocument.MM_Time[0]
[2].obj = document.all ? document.all["Layer1"]
:null;document.MM_Time[0][2].keyFrames = new Array(31,
45);document.MM_Time[0][2].values = new Array(2);if (ns5)
document.MM_Time[0][2].values[0] = new Array("183px", "191px","198px",
"206px", "213px", "221px", "228px", "236px", "243px", "251px","258px",
"266px", "273px", "281px", "288px"); elsedocument.MM_Time[0]
[2].values[0] = newArray
(183,191,198,206,213,221,228,236,243,251,258,266,273,281,288);document
.MM_Time[0][2].values[0].prop = "left";if (ns5)document.MM_Time[0]
[2].values[1] = new Array("18px", "23px", "28px","32px", "37px",
"42px", "47px", "51px", "56px", "61px", "66px", "71px", "75px","80px",
"85px");elsedocument.MM_Time[0][2].values[1] = newArray
(18,23,28,32,37,42,47,51,56,61,66,71,75,80,85);document.MM_Time[0]
[2].values[1].prop = "top";if (!ns4) {document.MM_Time[0][2].values
[0].prop2 = "style";document.MM_Time[0][2].values[1].prop2 =
"style";}document.MM_Time[0].lastFrame = 45;for (i=0;
i<document.MM_Time.length; i++) {document.MM_Time[i].ID =
null;document.MM_Time[i].curFrame = 0;document.MM_Time[i].delay =
1000/document.MM_Time[i].fps;}}//--></script></head><body
onLoad="MM_timelinePlay('Timeline1')"><div id="Layer1"
style="position:absolute; left:21px; top:16px;
width:192px;height:147px; z-index:1"><img src="1Tourism1.jpg"
name="Image1"width="196" height="141"></div></body></html>
SESSION 41 . Design a form as follows.<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled
Document</title><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head><body><form name="form1"><table
width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td
width="23%">Your name</td><td width="77%"><input type="text"
name="textfield"></td></tr><tr><td>Yi\our Address</td><td><input
type="text" name="textfield2"></td></tr><tr><td> </td><td><input
type="text" name="textfield3"></td></tr><tr><td>Your
Gender</td><td><input type="radio" name="radiobutton"
value="radiobutton">Male<input type="radio" name="radiobutton"
value="radiobutton">Female </td></tr><tr><td>Your
Country</td><td><select name="select"
size="1"><option>India</option><option>America</option><option>Canada<
/option><option>Denmark</option><option>Egypt</option><option>France</
option><option>Germany</option><option>Hungry</option></select></td></
tr><tr><td>Your
Opinion</td><td> </td></tr><tr><td> </td><td><textarea
name="textarea"
cols="50"></textarea></td></tr><tr><td> </td><td><input
type="reset" name="Reset" value="Reset"><input type="submit"
name="Submit2" value="Submit"></td></tr></table></form></body></html>
SESSION 21 . Insert an image in a page. In the browser, when you take
cursor over it, another image emerges under it and when you click on
the second image, it takes you toexercise 2 of session 1.<!DOCTYPE
HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Untitled Document</title><meta
http-equiv="Content-Type" content="text/html; charset=iso-8859-
1"><script language="JavaScript" type="text/JavaScript"><!--function
MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for
(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;} function
MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p)
d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new
Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01var
p,i,x; if(!d) d=document; if((p=n.indexOf("?"))
>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!
x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!
x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers
[i].document);if(!x && d.getElementById) x=d.getElementById(n); return
x;}function MM_swapImage() { //v3.0var
i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;for(i=0;i<
(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]
=x; if(!x.oSrc)x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body
onLoad="MM_preloadImages('animals7.JPG')"><a href="ex1session2.htm"
onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('Image1','','animals7.JPG',1)"><img src="12.jpg"name="Image1"
width="218" height="140" border="0"></a></body></html>
1.3 Java ScriptSession
14.How would you write any statement using only one write or writeln()
command?<html><head></head><script language="JavaScript">function
newpages(){document.writeln("Hi ");document.write("Welcome To My
Website");}</script><body><form name="form1" method="post" action="">
<p><input type="submit" name="Submit" value="Enter" onClick="newpages
()"></p></form></body></html>
5.Embed java script in html document asking user name and then
printing Hello<user Name>
<html><head></head><script language="JavaScript">function newpages
(txt){document.writeln("Hello " + txt);}</script><body><form
name="form1" method="post" action=""><p>Enter User Name<input
name="t1" type="text" id="t1"></p><p><input type="submit"
name="Submit" value="Enter"onClick="newpages
(form1.t1.value)"></p></form></body></html>
6.Create a dialogue box with “Welcome to my website” message.
<html><head></head><script language="JavaScript">alert("Welcome to my
website");</script><body></body></html>
=================================
Session 2
1.Evaluate the expressiona.
Ans. 7+5b. “7”+”5”c. 7*5d. 7/5e.7%5<html><head></head><script
language="JavaScript">function Calculate(choice){var result;switch
(choice)
{case 1:result=7+5; break;case 2:result="7" + "5"; break;case
3:result=7*5; break;case 4:result=7/5; break;case 5:result=7%5;
break;}document.writeln(result);}</script><body><form name="form1"
method="post" action=""> <p>Evaluate The
Expression</p><p><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate(1)">7+5</label><br><label><input
type="radio" name="RadioGroup1" value="radio"onClick="Calculate
(2)">"7" + "5"</label>
<br><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate(3)">7*5</label><br><label><input
type="radio" name="RadioGroup1" value="radio"onClick="Calculate
(4)">7/5</label><br><label><input type="radio" name="RadioGroup1"
value="radio"onClick="Calculate
(5)">7%5</label><br></p></form></body></html>
2. Write the segment of script that would ask the user if he wants a
greetingmessage and if he does, display a gif file called Welcome. gif
and display“Welcome to Netscape navigator!” in the document window
following the gif.<html><head></head><script
language="JavaScript">function messages(){input_box=confirm("Do You
Want a Greeting");if(input_box==true){window.open
("welcome.jpg");window.document.write("Welcome to Netscape navigator!"
);}else{alert("You Have Selected No");}}</script><body><form
name="form1" method="post" action=""><input type="submit"
name="Submit" value="Submit" onClick="messages
()"></form></body></html>
3.Write the object definition for an object called car with four
properties model,make, year and price.
<html><head><script language="JavaScript">var car=new
Object;car.model="Marcides
Benz";car.year=2008;car.make="DX";car.price=4500000;</script></head><s
cript language="JavaScript">function printdet(){document.write(" Model
: " + car.model);document.write(", Make : " +
car.make);document.write(", Year : " + car.year);document.write(",
Price : " +car.price);}</script><body><form name="form1" method="post"
action=""><input type="submit" name="Submit" value="Print Details"
onClick="printdet()"></form></body></html>
1.Write a program to display a multiplication
table.<html><head></head><script language="JavaScript">function
multable(){var num=prompt("Enter The No");var i;for(i=0;i<=10;i++)
{document.write(num + " * " + i + " = " + num*i +"<br>");}}
</script><body><form name="form1" method="post" action=""><input
type="submit" name="Submit" value="Print Details"onClick="multable
()"></form></body></html>
2.Write code to create a scrolling text.<html><head></head><script
language="JavaScript">function movetext(){if(txt.style.posLeft<720)
{txt.style.posLeft=txt.style.posLeft+2;window.setTimeout("movetext
()",5);}else{txt.style.posLeft=0;window.setTimeout("movetext()",5);}}
</script><body onLoad="movetext()"><form name="form1" method="post"
action=""><div id="txt"
style="position:relative;top:3;left0"><h2>Scrolling
Text</h2></div></form></body></html>
Session 42. Write a program to change color of text
randomly<html><head><script language="JavaScript">var colors=new
Array(6);colors[0]="#0000FF"; colors[1]="#FF0000"; colors[2]
="#006600";colors[3]="#FFCC00";colors[4]="#00FFFF"; colors[5]
="#000000";var i=1;</script></head><script
language="JavaScript">function changecolor(){ document.fgColor=colors
[i];i++;if(i>5)i=0;setTimeout("changecolor()",100);}</script><body
onLoad="changecolor()"><div align="center"><strong><font
size="7">Hello </font></strong> </div></body></html>
3.Create a web page using two image files, which switch b/w on another
as themouse pointer moves over the image. Use on mouse over and on
mouse out eventhandler.<html><head><script
language="JavaScript">function MM_swapImgRestore() {var
i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;}function MM_preloadImages() {var d=document; if
(d.images){ if(!d.MM_p) d.MM_p=new Array();var
i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;i
++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a
[i];}}}function MM_findObj(n, d) {var p,i,x; if(!d) d=document; if
((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames
[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all)
x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for
(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers
[i].document);if(!x && d.getElementById) x=d.getElementById(n); return
x;}function MM_swapImage() {var i,j=0,x,a=MM_swapImage.arguments;
document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)if
((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}}</script></head><body
onLoad="MM_preloadImages('welcome.JPG')"><a href="#"
onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('Image1','','welcome.JPG',1)"><imgsrc="Img1.jpg" name="Image1"
width="261" height="195" border="0"></a></body></html>
Session 52 . Use the date function get & set date to prompt the user
for an integer b/w 1-31 &return day of the week it
represents.<html><head></head><script language="JavaScript">function
setdate(){var dt=new Date();dt=new Date
(form1.y.value,form1.m.value,form1.d.value);form1.gt.value=dt.getDate
() + "/" + dt.getMonth() + "/" +dt.getFullYear();}</script><body><form
name="form1" method="post" action=""><p>Day <input name="d"
type="text" id="d" size="3">Month <input name="m" type="text" id="m"
size="3">Year <input name="y" type="text" id="y" size="4"><input
type="button" name="Button" value="SetDate" onClick="setdate
()"></p><p> Date <input name="gt" type="text" id="gt">
</p></form></body></html>
2.Display time and print the message accordingly e.g Good morning in
morning etc.<html><head><script language="JavaScript">var dt=new Date
();document.write("Good Morning The Time Is : " + dt.getHours() +":" +
dt.getMinutes() + ":" + dt.getSeconds
());</script></head><body></body></html>
Session 61.Using java script create a digital
clock.<html><head></head><script language="JavaScript">function
getTimes(){var dt=new Date();form1.t.value= dt.getHours() + ":" +
dt.getMinutes() + ":" + dt.getSeconds();window.setTimeout("getTimes
()",1000);}</script><body onLoad="getTimes()"><form name="form1"
method="post" action=""><input name="t" type="text"
id="t"></form></body></html>
Session 71.Using java script create a
calculator.<html><head></head><script language="JavaScript">function
calc(ch){if(ch=="=")form1.t.value= eval(form1.t.value);elseif
(ch=="C")form1.t.value= "";elseform1.t.value+=ch;}</script><body
onLoad="getTimes()"><form name="form1" method="post" action=""><input
name="t" type="text" id="t"><br><input type="button" name="Button"
value="7" onClick="calc('7')"><input type="button" name="Submit2"
value="8" onClick="calc('8')"><input type="button" name="Submit3"
value="9" onClick="calc('9')"> <input type="button" name="Submit4"
value="+" onClick="calc('+')"><br><input type="button" name="Submit5"
value="4" onClick="calc('4')"><input type="button" name="Submit6"
value="5" onClick="calc('5')"><input type="button" name="Submit7"
value="6" onClick="calc('6')"><input type="button" name="Submit8"
value="-" onClick="calc('-')"><br><input type="button" name="Submit9"
value="1" onClick="calc('1')"><input type="button" name="Submit10"
value="2" onClick="calc('2')"><input type="button" name="Submit11"
value="3" onClick="calc('3')"><input type="button" name="Submit12"
value="*" onClick="calc('*')"><br><input type="button" name="Submit13"
value="0" onClick="calc('0')"><input type="button" name="Submit14"
value="C" onClick="calc('C')"><input type="button" name="Submit15"
value="=" onClick="calc('=')"><br></form></body></html>
Session 81.Create a web page with a textbox and check for validation.
If empty displaymessage and set focus to it, if filled display thank
you.<html><head></head><script language="JavaScript">function check()
{if(form1.t.value==""){alert("Enter The Text");form1.t.focus();}else
{alert("Thank You");}}</script><body><form name="form1" method="post"
action="">Enter a Text<input name="t" type="text" id="t"><input
type="submit" name="Submit" value="Submit" onClick="check
()"></form></body></html>
Session 111. Create a program to generate a hit counter
<html><head></head><script language="JavaScript">var
counter;counter=0;function count(){counter++;alert("Counter : " +
counter);}</script><body><form name="form1" method="post"
action=""><div align="center"><input type="button" name="Button"
value="Hit Me" onClick="count()"></div></form></body></html>
2.Create a program to check email address provided by the user is
valid or invalid.<html><head></head><script
language="JavaScript">function check(){if(form1.t.value==""){alert
("Enter The Text");form1.t.focus();}else{var
email,a,d,diff,k,c;email=form1.t.value;a=email.indexOf
('@');d=email.indexOf('.');diff=parseInt(d)-parseInt(a);k=parseInt
(d)+1;c=email.charAt(k);if(a<1||diff<=1||c==""){alert("Invalid Email
ID");form1.t.focus();}}}</script><body><form name="form1"
method="post" action="">Enter Email ID <input name="t" type="text"
id="t"><input type="submit" name="Submit" value="Submit"
onClick="check()"></form></body></html>
Session 121.Write a program to scroll the text on status
bar.<html><head></head><html><head></head><script
language="JavaScript">var ar="Scrolling Text";var space="";var
i;i=1;function count(){var cont,k=0;cont="";while(k<=i){cont=cont + "
";k++;}status=cont +ar;i++;if(i>100)i=0;window.setTimeout("count
()",5);}</script><body onLoad="count
()"></body></html><body></body></html>
2. Write a program to create a small window in a main
window.<html><head><script language="JavaScript">window.open
("newwindow.html");</script></head><body></body></html>
Session 151.Use java script for authentication and verification of the
text boxes in the staticsite developed by the student in the html
exercise.<html><head></head><script language="JavaScript">function
check(){if(form1.t.value==""){alert("Enter The
Username");form1.t.focus();}else if(form1.t2.value==""){alert("Enter
The Password");form1.t2.focus();}else{if((form1.t.value!="")||
(form1.t2.value!=”")){alert("Invalid Username or Password");}}}
</script><body><form name="form1" method="post" action=""><p>User Name
<input name="t" type="text" id="t"> </p><p>Password <input name="t2"
type="password" id="t2"> </p><p> <input type="button" name="Button"
value="Button" onClick="check()"></p></form></body></html>
a.VB ScriptSession 11.Write a program to display the following on a
web pageHello <User Name><html><head></head><script
language="VBScript">sub newpages(txt)document.writeln("Hello " + txt)
end sub</script><body><form name="form1" method="post"
action=""><p>Enter User Name<input name="t1" type="text"
id="t1"></p><p><input type="submit" name="Submit"
value="Enter"onClick="newpages
(form1.t1.value)"></p></form></body></html>
2.Create a web page that display a message box with the
message“welcome to my web site”<html><head></head><script
language="VBScript">sub msgs()msgbox("Welcome To My Web Site")end
sub</script><body><form name="form1" method="post" action=""><p>
<input type="submit" name="Submit" value="Message"onClick="msgs()">
</p></form></body></html>
3.Write code to change color of text
randomly.<html><head></head><script language="VBScript">dim colors(5)
colors(0)="#0000FF"colors(1)="#FF0000"colors(2)="#006600"colors(3)
="#FFCC00"colors(4)="#00FFFF"colors(5)="#000000"dim ii=0sub
changecolor()msgbox("Welcome To My Web Site")document.fgColor=colors
(i)i=i+1if(i>5) theni=0end if window.setTimeout("changecolor()",100)
end sub</script><body onLoad="changecolor()"><div
align="center"><strong><font size="7">Hello </font></strong>
</div></body></html>
Session 21.Write a VB Script code that accepts the length, breadth and
height and display thearea of a rectangle.<html><head></head><script
language="VBScript">sub area()dim l,b,h,ar 40
l=form1.l.value b=form1.b.valueh=form1.h.valuear=l*b*hmsgbox("Area " &
ar)end sub</script><body onLoad="changecolor()"><form name="form1"
method="post" action="">Length <input name="l" type="text"
id="l">Breadth <input name="b" type="text" id="b">Height <input
name="h" type="text" id="h"><br><input type="button" name="Button"
value="Area" onClick="area()"></form></body></html>
2.Create a programme to generate a hit counter
<html><head></head><script language="VBScript">dim counter
counter=0sub count()counter=counter+1msgbox("Counter : " & counter)end
sub</script><body><form name="form1" method="post" action=""><div
align="center"><input type="button" name="Button" value="Hit Me"
onClick="count()"></div></form></body></html>
Session 31.Using vbscript create a calculator
<html><head></head><script language="VBScript">sub calc(ch)if(ch="=")
then form1.t.value= eval(form1.t.value)elseif(ch="C")
thenform1.t.value= ""elseform1.t.value=form1.t.value & chend if end if
end sub</script><body onLoad="getTimes()"><form name="form1"
method="post" action=""><input name="t" type="text" id="t"><br><input
type="button" name="Button" value="7" onClick="calc('7')"><input
type="button" name="Submit2" value="8" onClick="calc('8')"><input
type="button" name="Submit3" value="9" onClick="calc('9')"><input
type="button" name="Submit4" value="+" onClick="calc('+')"><br><input
type="button" name="Submit5" value="4" onClick="calc('4')"><input
type="button" name="Submit6" value="5" onClick="calc('5')"><input
type="button" name="Submit7" value="6" onClick="calc('6')"><input
type="button" name="Submit8" value="-" onClick="calc('-')"><br><input
type="button" name="Submit9" value="1" onClick="calc('1')"><input
type="button" name="Submit10" value="2" onClick="calc('2')"><input
type="button" name="Submit11" value="3" onClick="calc('3')"><input
type="button" name="Submit12" value="*" onClick="calc('*')"><br><input
type="button" name="Submit13" value="0" onClick="calc('0')"><input
type="button" name="Submit14" value="C" onClick="calc('C')"><input
type="button" name="Submit15" value="=" onClick="calc
('=')"><br></form></body></html>
Session 41.Create a programme to check for null or empty
string<html><head></head><script language="VBScript">sub check()if
(form1.t.value="")thenmsgbox("Enter The Text")form1.t.focus()
elsealert("Thank You")end if end sub</script><body><form name="form1"
method="post" action="">Enter a Text<input name="t" type="text"
id="t"><input type="submit" name="Submit" value="Submit"
onClick="check()"></form></body></html>
2.Create a form that has e-mail field. Now Write VB Script code for
Validation.<html><head></head><script language="VBScript">sub check()
if(form1.t.value="")thenalert("Enter The Text")form1.t.focus()elsedim
email,a,d,diff,k,cemail=form1.t.valuea=InStr(1,email,"@")d=InStr
(1,email,".")diff=d-ak=d+1c=Mid(email, k, 1)if(a<1 or diff<=1 or
c="")thenalert("Invalid Email ID")form1.t.focus()end if end if end
sub</script><body><form name="form1" method="post" action="">Enter
Email ID <input name="t" type="text" id="t"><input type="submit"
name="Submit" value="Submit" onClick="check()"></form></body></html>
Session 51.List Mouse and Key events in vbscriptMouse Events :
MouseOver, MouseOutKey Events : KeyUp,KeyDown,KeyRelease,
KeyPress2.How do you create random numbers in vbscript?Random No is
Generated byRndFunction
Session 61.Create a form in HTML containing the following files and
then perform thevalidation of each field using VBScript. Name-
textboxAddress-textboxDate Of Birth-Combo boxEmail-
textbox<html><head></head><script language="VBScript">sub check()if
(form1.n.value="")thenalert("Enter The Name")form1.n.focus()elseif
(form1.a.value="")thenalert("Enter The Address")form1.a.focus()elseif
(form1.y.value="")thenalert("Enter The Year")form1.y.focus()elseif
(form1.d.value="")thenalert("Select The Day")form1.d.focus()elseif
(form1.m.value="")thenalert("Select The Month")form1.m.focus()elseif
(form1.mail.value="")thendim
email,a,d,diff,k,cemail=form1.t.valuea=InStr(1,email,"@")d=InStr
(1,email,".")diff=d-ak=d+1c=Mid(email, k, 1)if(a<1 or diff<=1 or
c="")thenalert("Invalid Email ID")form1.t.focus()end if end if end
sub</script><body><form name="form1" method="post"
action=""><p>Name<input name="n" type="text" id="n"><br>Address<input
name="a" type="text" id="a"><br>Date Of Birth : Day<select name="d"
id="d"
><option>1</option><option>2</option><option>3</option><option>4</opti
on><option>5</option><option>6</option><option>7</option><option>8</op
tion><option>9</option><option>10</option>
<option>11</option><option>12</option><option>13</option><option>14</o
ption><option>15</option><option>16</option><option>17</option><option
>18</option><option>19</option><option>20</option>
<option>21</option><option>22</option><option>23</option><option>24</o
ption><option>25</option><option>26</option><option>27</option><option
>28</option><option>29</option><option>30</option><option>31</option><
/select>Month<select name="m"
id="m"><option>Jan</option><option>Feb</option><option>Mar</option><op
tion>Aprl</option><option>May</option><option>Jun</option><option>July
</option><option>Aug</option><option>Sep</option><option>Oct</option><
option>Nov</option><option>Dec</option></select>Year <input name="y"
type="text" id="y" size="6"><br>Email Id <input name="mail"
type="text" id="mail"><br> <input type="button" name="Button"
value="Button"onClick="check()"></form></body></html>
Session 8
1.Create a program the accepts the time from the system clock and
accordinglydisplays a Good morning, Good Afternoon and Good Evening
message to the user <html><head></head><script language="VBScript">sub
wish()dim hh=Datepart("h",Now)if h>=1 and h<=12 thenmsgbox("Good
Morning")elseif h>=13 and h<=18 thenmsgbox("Good Afternoon")
elsemsgbox("Good Evening")end if end sub</script><body onLoad="wish
()"></body></html>
Session 91.Write a programme that uses For next Looping Statements to
create a FibonacciSeries.<html><head></head><script
language="VBScript">sub fib()dim a,b,ca=1 b=1document.write("First 10
Fibonacci Series<br>")document.write(a & " " & b &
" ")for i=3 to 10c=cint(a)+cint(b)document.write(c &
" ")a=b b=cnextend sub</script><body onLoad="fib
()"></body></html>
2.Using Do While display the factorial of a
number.<html><head></head><script language="VBScript">sub fact(n)dim
f,if=1i=1do while(i<=cint(n))f=cint(f)*cint(i)i=i+1loopdocument.write
("<br>Factorial Of " & n & " is " & f)end sub</script><body><form
name="form1" method="post" action=""><input name="n" type="text"
id="n"><input name="Button" type="button" onClick="fact
(form1.n.value)"value="Factorial"></form></body></html>
Session 101.Write a Program that displays the multiplication of two
matrices.<html><head></head><script language="VBScript">sub matmul()
dim m1(3,3),m2(3,3),m3(3,3),count,i,jcount=0msgbox("Enter First
matrix")for i=0 to 2for j=0 to 2m1(i,j)=inputbox("")nextnextmsgbox
("Enter Seconf matrix")for i=0 to 2for j=0 to 2m2(i,j)=inputbox("")
next nextdocument.write("<br>Product of two Matrix<br>")for i=0 to
2for j=0 to 2for k=0 to 2m3(i,j)=cint(m3(i,j))+cint(m1(i,k))* cint(m2
(k,j))nextnextnextfor i=0 to 2for j=0 to 2document.write(" " & m1
(i,j))nextdocument.write("<br>")nextdocument.write("<br>+<br>")for i=0
to 2for j=0 to 2document.write(" " & m2(i,j))nextdocument.write
("<br>")nextdocument.write("<br>=<br>")for i=0 to 2for j=0 to
2document.write(" " & m3(i,j))nextdocument.write("<br>")nextend
sub</script><body onLoad="matmul()"></body>
3 . Write a program that accepts a number from the user and displays
its factorialonly if it is a prime number.<html><head></head><script
language="VBScript">sub ChkPrime(n)dim i,prime,k prime=truefor i=2 to
cint(n)/2if (n Mod i)=0 thenprime=falseend if nextif prime=true
thenfact(n)elsedocument.write("<br>The Number is Not Prime")end if end
subsub fact(n)dim f,if=1i=1do while(i<=cint(n))f=cint(f)*cint(i)i=i
+1loopdocument.write("<br>Factorial Of " & n & " is " & f)end
sub</script><body><form name="form1" method="post" action=""><input
name="n" type="text" id="n"><input name="Button" type="button"
onClick="ChkPrime
(form1.n.value)"value="factorial"></form></body></html>
DreamweaverSESSION 11.Design a home page of your TLC.<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Untitled Document</title><meta
http-equiv="Content-Type" content="text/html; charset=iso-8859-
1"></head><body><table width="100%" border="1" cellpadding="0"><tr><td
bgcolor="#ccc123"><div align="center"><strong><font
size="6">IGNOUPROGRAM STUDY
CENTER</font></strong></div></td></tr><tr><td bgcolor="#cccc12"><div
align="center"><strong><font size="6">WELCOMETO
</font></strong></div></td></tr><tr><td bgcolor="pink"><div
align="center"><strong><br><font size="4"><a
href="faculty_coord.html">FACULTIES ANDCOORDINATORS</a><br><a
href="theory_b_schedule.html">THEORY BATCH SCHEDULES</a> <br><a
href="prac_b_schedule.html">PRACTICAL BATCH SCHEDULES</a><br><a
href="sem_detail.html">SEMESTER WISE LIST OF STUDENTS</a> <br><a
href="assignment.html">ASSIGNMENT AND VIVA-VOCE</a> <br><a
href="ask_y_question.htm">ASK YOUR QUESTION</a> <br><a
href="mail.htm">MAIL US</a>
</font></strong><fontsize="4"></font></div></td></tr></table><p
align="center"><br></p></body></html>
2.Design a Home Page for a toy Company. The page has an image as th
background. Do some text attracting format.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Toy Page</title><meta http-
equiv="Content-Type" content="text/html; charset=iso-8859-
1"></head><body background="646.jpg"><table width="100%" border="0"
cellpadding="0"><tr><td><div align="center"><strong><font
color="#33FF00" size="7">Tom
ToysCenter</font></strong></div></td></tr><tr><td> </td></tr><tr>
<td align="left" valign="top"><table width="100%"
border="1"cellpadding="0"><tr><td width="27%"><table width="100%"
border="1" cellpadding="0"><tr><td><div align="center"><font
size="5"><strong><ahref="prof.htm">Profiles</a></strong></font></div><
/td></tr><tr><td><div align="center"><font
size="5"><strong><ahref="Toys.htm">Toys</a></strong></font></div></td>
</tr><tr><td><div align="center"><font
size="5"><strong><ahref="cont.htm">ContactUs</a></strong></font></div>
</td></tr></table></td><td width="73%" align="left" valign="top"><div
align="justify"><fontcolor="#FFFFFF" size="4">We are one of the
leading toy comapny in the city and have branchesin all major
districts thoughout kerala. Our toy Shope containsa vide variety of
collection of toys which taste the choice of your kids. toys posses a
high quality . the toys are normally importedfrom European and
American
Countries.</font></div></td></tr></table></td></tr><tr><td> </td>
</tr></table></body></html>
3.Insert a image in your page and give a zig zag motion to the image
in you page(using timeline).<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN"><html><head><title>Untitled
Document</title><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"><script language="JavaScript"
type="text/JavaScript"><!--function MM_timelinePlay(tmLnName, myID) {
//v1.2//Copyright 1997, 2000 Macromedia, Inc. All rights reserved.var
i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstT
ime=false;if (document.MM_Time == null) MM_initTimelines(); //if
*very* 1st timetmLn = document.MM_Time[tmLnName];if (myID == null) {
myID = ++tmLn.ID; firstTime=true;}//if new call, incr IDif (myID ==
tmLn.ID) { //if Im newestsetTimeout('MM_timelinePlay("'+tmLnName
+'",'+myID+')',tmLn.delay);fNew = ++tmLn.curFrame;for (i=0;
i<tmLn.length; i++) {sprite = tmLn[i];if (sprite.charAt(0) == 's') {if
(sprite.obj) {numKeyFr = sprite.keyFrames.length; firstKeyFr =
sprite.keyFrames[0];if (fNew >= firstKeyFr && fNew <=
sprite.keyFrames[numKeyFr-1]) {//inrangekeyFrm=1;for (j=0;
j<sprite.values.length; j++) {props = sprite.values[j];if (numKeyFr !=
props.length) {if (props.prop2 == null) sprite.obj[props.prop] =
props[fNew-firstKeyFr];else sprite.obj[props.prop2][props.prop] =
props[fNew-firstKeyFr];} else {while (keyFrm<numKeyFr &&
fNew>=sprite.keyFrames[keyFrm])keyFrm++;if (firstTime ||
fNew==sprite.keyFrames[keyFrm-1]) {if (props.prop2 == null)
sprite.obj[props.prop] = props[keyFrm-1];else sprite.obj[props.prop2]
[props.prop] = props[keyFrm-1];} } } } }} else if (sprite.charAt(0)
=='b' && fNew == sprite.frame) eval(sprite.value);if (fNew >
tmLn.lastFrame) tmLn.ID = 0;} }}function MM_initTimelines() {
//v4.0//MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights
reserved.var ns = navigator.appName == "Netscape";var ns4 = (ns &&
parseInt(navigator.appVersion) == 4);var ns5 = (ns && parseInt
(navigator.appVersion) > 4);document.MM_Time = new Array
(1);document.MM_Time[0] = new Array(3);document.MM_Time["Timeline1"] =
document.MM_Time[0];document.MM_Time[0].MM_Name =
"Timeline1";document.MM_Time[0].fps = 15;document.MM_Time[0][0] = new
String("sprite");document.MM_Time[0][0].slot = 1;if (ns4)
document.MM_Time[0][0].obj = document["Layer1"];else if (ns5)
document.MM_Time[0][0].obj = document.getElementById
("Layer1");elsedocument.MM_Time[0][0].obj = document.all ?
document.all["Layer1"] :null;document.MM_Time[0][0].keyFrames = new
Array(1, 15);document.MM_Time[0][0].values = new Array(2);if (ns5)
document.MM_Time[0][0].values[0] = new Array("21px", "24px",
"28px","31px", "35px", "38px", "42px", "45px", "48px", "52px", "55px",
"59px", "62px","66px", "69px");elsedocument.MM_Time[0][0].values[0] =
newArray
(21,24,28,31,35,38,42,45,48,52,55,59,62,66,69);document.MM_Time[0]
[0].values[0].prop = "left";if (ns5)document.MM_Time[0][0].values[1] =
new Array("16px", "21px", "25px","30px", "35px", "39px", "44px",
"48px", "53px", "58px", "62px", "67px", "72px","76px", "81px");else
document.MM_Time[0][0].values[1] = newArray
(16,21,25,30,35,39,44,48,53,58,62,67,72,76,81);document.MM_Time[0]
[0].values[1].prop = "top";if (!ns4) {document.MM_Time[0][0].values
[0].prop2 = "style";document.MM_Time[0][0].values[1].prop2 =
"style";}document.MM_Time[0][1] = new String
("sprite");document.MM_Time[0][1].slot = 1;if (ns4)document.MM_Time
[0][1].obj = document["Layer1"];else if (ns5)document.MM_Time[0]
[1].obj = document.getElementById("Layer1");elsedocument.MM_Time[0]
[1].obj = document.all ? document.all["Layer1"]
:null;document.MM_Time[0][1].keyFrames = new Array(16,
30);document.MM_Time[0][1].values = new Array(2);if (ns5)
document.MM_Time[0][1].values[0] = new Array("69px", "77px",
"85px","93px", "102px", "110px", "118px", "126px", "134px", "142px",
"150px","159px", "167px", "175px", "183px"); elsedocument.MM_Time[0]
[1].values[0] = newArray
(69,77,85,93,102,110,118,126,134,142,150,159,167,175,183);document.MM_
Time[0][1].values[0].prop = "left"; if (ns5)document.MM_Time[0]
[1].values[1] = new Array("81px", "77px", "72px","68px", "63px",
"59px", "54px", "50px", "45px", "41px", "36px", "32px", "27px","22px",
"18px");elsedocument.MM_Time[0][1].values[1] = newArray
(81,77,72,68,63,59,54,50,45,41,36,32,27,22,18);document.MM_Time[0]
[1].values[1].prop = "top";if (!ns4) {document.MM_Time[0][1].values
[0].prop2 = "style";document.MM_Time[0][1].values[1].prop2 =
"style";}document.MM_Time[0][2] = new String
("sprite");document.MM_Time[0][2].slot = 1;if (ns4)document.MM_Time
[0][2].obj = document["Layer1"];else if (ns5)document.MM_Time[0]
[2].obj = document.getElementById("Layer1");elsedocument.MM_Time[0]
[2].obj = document.all ? document.all["Layer1"]
:null;document.MM_Time[0][2].keyFrames = new Array(31,
45);document.MM_Time[0][2].values = new Array(2);if (ns5)
document.MM_Time[0][2].values[0] = new Array("183px", "191px","198px",
"206px", "213px", "221px", "228px", "236px", "243px", "251px","258px",
"266px", "273px", "281px", "288px"); elsedocument.MM_Time[0]
[2].values[0] = newArray
(183,191,198,206,213,221,228,236,243,251,258,266,273,281,288);document
.MM_Time[0][2].values[0].prop = "left";if (ns5)document.MM_Time[0]
[2].values[1] = new Array("18px", "23px", "28px","32px", "37px",
"42px", "47px", "51px", "56px", "61px", "66px", "71px", "75px","80px",
"85px");elsedocument.MM_Time[0][2].values[1] = newArray
(18,23,28,32,37,42,47,51,56,61,66,71,75,80,85);document.MM_Time[0]
[2].values[1].prop = "top";if (!ns4) {document.MM_Time[0][2].values
[0].prop2 = "style";document.MM_Time[0][2].values[1].prop2 =
"style";}document.MM_Time[0].lastFrame = 45;for (i=0;
i<document.MM_Time.length; i++) {document.MM_Time[i].ID =
null;document.MM_Time[i].curFrame = 0;document.MM_Time[i].delay =
1000/document.MM_Time[i].fps;}}//--></script></head><body
onLoad="MM_timelinePlay('Timeline1')"><div id="Layer1"
style="position:absolute; left:21px; top:16px;
width:192px;height:147px; z-index:1"><img src="1Tourism1.jpg"
name="Image1"width="196" height="141"></div></body></html>
SESSION 41 . Design a form as follows.<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled
Document</title><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head><body><form name="form1"><table
width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td
width="23%">Your name</td><td width="77%"><input type="text"
name="textfield"></td></tr><tr><td>Yi\our Address</td><td><input
type="text" name="textfield2"></td></tr><tr><td> </td><td><input
type="text" name="textfield3"></td></tr><tr><td>Your
Gender</td><td><input type="radio" name="radiobutton"
value="radiobutton">Male<input type="radio" name="radiobutton"
value="radiobutton">Female </td></tr><tr><td>Your
Country</td><td><select name="select"
size="1"><option>India</option><option>America</option><option>Canada<
/option><option>Denmark</option><option>Egypt</option><option>France</
option><option>Germany</option><option>Hungry</option></select></td></
tr><tr><td>Your
Opinion</td><td> </td></tr><tr><td> </td><td><textarea
name="textarea"
cols="50"></textarea></td></tr><tr><td> </td><td><input
type="reset" name="Reset" value="Reset"><input type="submit"
name="Submit2" value="Submit"></td></tr></table></form></body></html>
SESSION 21 . Insert an image in a page. In the browser, when you take
cursor over it, another image emerges under it and when you click on
the second image, it takes you toexercise 2 of session 1.<!DOCTYPE
HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><html><head><title>Untitled Document</title><meta
http-equiv="Content-Type" content="text/html; charset=iso-8859-
1"><script language="JavaScript" type="text/JavaScript"><!--function
MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for
(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;} function
MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p)
d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new
Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01var
p,i,x; if(!d) d=document; if((p=n.indexOf("?"))
>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!
x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!
x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers
[i].document);if(!x && d.getElementById) x=d.getElementById(n); return
x;}function MM_swapImage() { //v3.0var
i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;for(i=0;i<
(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]
=x; if(!x.oSrc)x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body
onLoad="MM_preloadImages('animals7.JPG')"><a href="ex1session2.htm"
onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('Image1','','animals7.JPG',1)"><img src="12.jpg"name="Image1"
width="218" height="140" border="0"></a></body></html>