0% found this document useful (0 votes)
10 views12 pages

Javascript Practical

Uploaded by

Kaustubh Palkar
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)
10 views12 pages

Javascript Practical

Uploaded by

Kaustubh Palkar
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/ 12

JAVASCRIPT

SOP1:

Color.html

<!DOCTYPE html>

<html>

<head>

<title>color change</title>

<script type="text/Javascript">

function f1()

document.bgColor="Blue";

window.setTimeout("f2()",2000);

function f2()

document.bgColor="Red";

window.setTimeout("f3()",2000);

function f3()

document.bgColor="Green";

window.setTimeout("f4()",2000);

function f4()

document.bgColor="Yellow";

window.setTimeout("f5()",2000);

function f5()

document.bgColor="magenta";

window.setTimeout("f6()",2000);
}

function f6()

document.bgColor="purple";

window.setTimeout("f7()",2000);

function f7()

document.bgColor="black";

window.setTimeout("f1()",2000);

</script>

</head>

<body>

<form>

<input type="button" onMouseOver="f1()" value="color">

</form>

</body>

</html>

Color1.html

<!DOCTYPE html>

<html>

<head>

<title>EVENT DRIVEN</title>

<script type="text/javascript">

function f1()

document.bgColor="Blue"

window.setTimeout("f2()",2000)

}
function f2()

document.bgColor="Red"

window.setTimeout("f3()",2000)

function f3()

document.bgColor="Green"

window.setTimeout("f4()",2000)

function f4()

document.bgColor="Yellow"

window.setTimeout("f5()",2000)

function f5()

document.bgColor="orange"

window.setTimeout("f6()",2000)

function f6()

document.bgColor="cyan"

window.setTimeout("f7()",2000)

function f7()

document.bgColor="aqua"

window.setTimeout("f1()",2000)

</script>

</head>
<body onLoad="f1()">

</body></html>
SOP5:

Cel and far.html

<!DOCTYPE html>

<html>

<head>

<title>Celsius to Farenheit</title>

</head>

<body >

<p><input type="text" id ="c" onkeyup="convert('C')">Degree Celsius</p>

<p><input type="text" id ="f" onkeyup="convert('F')">Degree Fareneit</p>

<script type="text/javascript">

function convert(degree)

var x;

if(degree=="C")

x=document.getElementById("c").value*9/5+32;

document.getElementById("f").value=x;

else

if(degree=="F")

x=((document.getElementById("f").value-32)*5/9);

document.getElementById("c").value=x;

}
}

</script>

</body>

</html>
SOP3 : Create event driven Javascript program for the following …………

Vowels.html

<!DOCTYPE html>

<html>

<head>

<title>Vowels</title>

<body>

<form name="f1">

Enter String:<input type=text name=t1><br>

<input type="button" value="count down" onClick="voc()">

</form>

<script type="text/Javascript">

function voc()

var s,i,ch,c;

c=0;

s=f1.t1.value;

for(i=0;i<=s.length;i++)
{

ch=s.charAt(i);

if(ch=="a"||ch=="e"||ch=="i"||ch=="o"||ch=="u"||ch=="A"||ch=="E"||ch=="I"||ch=="O"||ch=="
U")

c++;

alert("Number of Vowels in string are "+c);

</script>

</body>

</html>
SOP6:Create Javascript program which computes the average……………

Grade.html

<!DOCTYPE html>

<head>

<title>Grades</title>

<script type="text/javascript">

function grade()

var a1,a2,a3,a4,a5,m;

a1=parseInt(mn.t1.value);

a2=parseInt(mn.t2.value);

a3=parseInt(mn.t3.value);

a4=parseInt(mn.t4.value);

a5=parseInt(mn.t5.value);

m=(a1+a2+a3+a4+a5)/5;

alert("Average Marks of Student is : "+m);

if(m>=91)

alert("Grade A");

else

if(m>=81)

alert("Grade B");

else

if(m>=71)

alert("Grade C");

else

if(m>=61)

alert("Grade D");
else

alert("Grade F");

</script>

</head>

<body bgcolor="pink">

<form name="mn">

Enter Marks of English : <input type="number" name="t1"><br><br>

Enter Marks of Maths : <input type="number" name="t2"><br><br>

Enter Marks of Physics : <input type="number" name="t3"><br><br>

Enter Marks of Chemistry : <input type="number" name="t4"><br><br>

Enter Marks of I.T : <input type="number" name="t5"><br><br>

<input type="button" name="pq" value="Grades" onClick="grade()">

</form>

</body>

You might also like