Javascript SOP For Printout
Javascript SOP For Printout
setTimeout("f1()",3000);
<!DOCTYPE html> }
<html> function msg()
<head> {
<title> window.status="Display of 7 different colors";
Background Colors }
</title> </script>
</head> </html>
<body>
<h1 align="center">7 Different & visibly distinct
background colors</h1>
<form name="frm1">
<center>
<input type="button" name="btncolor"
value="Change Colors" onMouseOver="f1()">
<input type="button" name="btnmsg"
value="Message Display" onClick="msg()">
</form>
</body>
<script type="text/javascript">
function f1()
{
document.bgColor="red";
window.setTimeout("f2()",3000);
}
function f2()
{
document.bgColor="green";
window.setTimeout("f3()",3000);
}
function f3()
{
document.bgColor="pink";
window.setTimeout("f4()",3000);
}
function f4()
{
document.bgColor="orange";
window.setTimeout("f5()",3000);
}
function f5()
{
document.bgColor="skyblue";
window.setTimeout("f6()",3000);
}
function f6()
{
document.bgColor="voilet";
window.setTimeout("f7()",1500);
}
function f7()
{
document.bgColor="aqua";
SOP 2 Telephone validation
<html>
<body>
<form name="frm1">
Enter Name
<input type="text" name="t1"><br><br>
Enter Address<br>
<textarea name="t2"
placeholder="PERMENANT
ADDRESS"></textarea><br><br>
Enter Telehpone Number
<input type="tel"
maxlength="10"><br><br>
Enter Email Address
<input type="email" name="t3"
pattern="[A-Z a-z]{5}-[@]{1}-[.]{1}"
placeholder="[email protected]">
<br><br>
<input type="button" name="b1"
value="Submit" onClick="chk()">
</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||dotpos+2>=x
.length||firstdot<atpos||atpos<lastat)
{
alert("Not a valid email address");
frm1.t3.focus();
}
else
{
alert("Email address is accepted");
return true;
}
}
</script>
</html>
SOP 3 Celsius
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Celcius to
Fahrenhet</h2>
<p>Insert a number into one of the
input fields below:</p>
<p><input type="text" id="c"
onkeyup="convert('C')"> Degrees
Celsius</p>
<p><input type="text" id="f"
onkeyup="convert('F')"> degrees
Fahrenheit</p>
<p>Note that the
<b>Math.round()</b> method is
used, so that the result will be
returned as an integer.</p>
<script type=”text/javascript”>
function convert(degree)
{
var x;
if (degree == "C")
{
x=
document.getElementById("c").val
ue * 9 / 5 + 32;
document.getElementById("f").val
ue = Math.round(x);
}
else
{
x=
(document.getElementById("f").val
ue -32) * 5 / 9;
document.getElementById("c").val
ue = Math.round(x);
}
}
</script>
</body>
</html>
SOP 4 Average marks "+a);
<!DOCTYPE html>
if(a>=91)
<html>
alert("Grade A");
<body>
else
<form name="frm1">
{
Enter Marks of English
if(a>=81)
<input type="number"
name="t1"><br><br> alert("Grade B");
<input type="number" {
name="t2"><br><br> if(a>=71)
Enter Marks of Physics alert("Grade C");
<input type="number" else
name="t3"><br><br>
{
Enter Marks of Chemistry
if(a>=61)
<input type="number"
name="t4"><br><br> alert("Grade D");