SOP Javascript
SOP Javascript
<!--
Javascript SOP 1: Create a web page in HTML having a white background and two button objects. write
code using javascript such that when the mouse is placed over the first button object without clicking,
the color of the background of the page should change after every seconds. There should at least be 7
different and visibly distinct background colors excluding the default color. When the second button
object is clicked, appropriate message should be displayed in Browsers status bar. Create another web
page using Javascript where the background color changes automatically after every seconds. This event
must be triggered automatically after the page get loaded in the browser. There should at least be 7
differentand visibly distinct background colors. When the page is unloaded, the appropriate alert
message should be displayed. -->
<!doctype html>
<html>
<head>
</title>
</head>
<body bgcolor="pink">
<form name="frm1">
<center>
</form>
</body>
<script type="text/Javascript">
function f1()
document.bgColor="red";
window.setTimeout("f2()",1500);
function f2()
document.bgColor="green";
window.setTimeout("f3()",1500);
function f3()
document.bgColor="blue";
window.setTimeout("f4()",1500);
function f4()
document.bgColor="yellow";
window.setTimeout("f5()",1500);
function f5()
document.bgColor="aqua";
window.setTimeout("f6()",1500);
}
function f6()
document.bgColor="violet";
window.setTimeout("f7()",1500);
function f7()
document.bgColor="organge";
window.setTimeout("f8()",1500);
function f8()
document.bgColor="grey";
window.setTimeout("f1()",1500);
function dispaly()
}
<!doctype html>
<html>
<head>
</head>
</body>
<script type="text/Javascript">
function f1()
document.bgColor="red";
window.setTimeout("f2()",1500);
function f2()
document.bgColor="green";
window.setTimeout("f3()",1500);
function f3()
document.bgColor="blue";
window.setTimeout("f4()",1500);
}
function f4()
document.bgColor="yellow";
window.setTimeout("f5()",1500);
function f5()
document.bgColor="aqua";
window.setTimeout("f6()",1500);
function f6()
document.bgColor="violet";
window.setTimeout("f7()",1500);
function f7()
document.bgColor="organge";
window.setTimeout("f8()",1500);
function f8()
document.bgColor="grey";
window.setTimeout("f1()",1500);
}
function msg()
}
SOP2 Javascript
<!--
javascript SOP 2: Create JavaScript program for the following form validations.
1) Name, address, contact number and email are required fields of the form
2) Address field should show the hint value which will disappear when field
4) Email field should contain valid email address, @ should appear only once
and not at the beginning or at the end. It must contain at least one dot(.).
5) Make use of pattern attribute for email to accept lowercase, uppercase alphbets,
--->
<!doctype html>
<html>
<head>
</head>
<body>
<form name="frm1">
Enter Name:
Enter Address:
<br> <br>
</form>
</body>
<script type="text/javascript">
function chk()
var x=frm1.t3.value;
var atpos=x.indexOf("@");
var lastat=x.lastIndexOf("@");
var firstdot=x.indexOf(".");
var dotpos=x.lastIndexOf(".");
if( atpos < 1 || dotpos < atpos + 2 >= x.length || firstdot < atpos || atpos < lastat )
frm1.t3.focus();
else
</script>
</html>
SOP3 javascript
<!---
Javascript SOP 3: Create event driven Javascript program for the following. Make use of appropriate
variables, Javascript inbuilt string functions and control structures. To string from user and count
-->
<!doctype html>
<html>
<head>
</head>
<body bgcolor="pink">
<form name="frm1">
</form>
</body>
<script type="text/javascript">
function cnt()
var s,i,ch,c;
c=0;
s=frm1.t1.value;
ch=s.charAt(i);
if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u')
c++;
</script>
</html>
SOP4 Javascrip
<!--
javascript SOP: 4
Create event driven Javascript program for the following. Make use
structures.
To accept string from user and reverse the given string and check
-->
<!doctype html>
<html>
<head>
<title>Palindrome Checker</title>
</head>
<body bgcolor="pink">
<form name="frm1">
</form>
<script type="text/javascript">
function chk() {
var a, s, i, n;
a = frm1.t1.value;
n = s.length;
var p = 1;
p = 0;
break;
if (p === 1) {
alert("String is Palindrome");
} else {
</script>
</body>
</html>
SOP5 javascript
Celsius , Fahrenheit.
Formula c/5=((f-32))/9
f= Temperature in Fahrenheit.)
<!DOCTYPE html>
<html>
<body>
<p>Note that the <b>Math.round()</b> method is used, so that the result will be returned as an
integer.</p>
<script>
function convert(degree) {
var x;
if (degree == "C") {
x = document.getElementById("c").value * 9 / 5 + 32;
document.getElementById("f").value = Math.round(x);
} else {
x = (document.getElementById("f").value -32) * 5 / 9;
document.getElementById("c").value = Math.round(x);
</script>
</body>
</html>
SOP6 javascript
<!-- SOP 6: Create Javascript program which compute the average marks of
average marks of student which is used to determine the corresponding grades. -->
<!doctype html>
<head>
</head>
<body>
<form name="frm1">
Enter Marks of Physic:              
   
</form>
</body>
<script type="text/javascript">
function grade()
var m1,m2,m3,m4,m5,m6,a;
m1=parseFloat(frm1.t1.value);
m2=parseFloat(frm1.t2.value);
m3=parseFloat(frm1.t3.value);
m4=parseFloat(frm1.t4.value);
m5=parseFloat(frm1.t5.value);
m6=parseFloat(frm1.t6.value);
a=m1+m2+m3+m4+m5+m6;
alert(a)
var b= a/6;
if(a>91)
alert("Grade A");
else
{
if(a>81)
alert("Grade is B");
else
if(a>71)
alert("Grade is C");
else
if(a>61)
alert("Grade is D");
else
alert("Grade is F");
</script>
<html>