Javascript Coding
Javascript Coding
--------------------------------------------------------------------------------------------------------------------------------------
COLOR.HTML
<!DOCTYPE html>
<html>
<head>
<title>
Background Colurs
</title>
</head>
<body>
<form name="frml">
<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="pink";
window.setTimeout("f4()",1500);
function f4()
document.bgColor="orange";
window.setTimeout("f5()",1500);
function f5()
document.bgColor="skyblue";
window.setTimeout("f6()",1500);
function f6()
document.bgColor="voilet";
window.setTimeout("f7()",1500);
function f7()
document.bgColor="aqua";
window.setTimeout("f8()",1500);
}
function msg()
</script>
</html>
EMAIL.HTML
<html>
<body>
<form name="frm1">
Enter Name
Enter Address<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+211||dotpos+2>=x.length||firstdot<atpos||atpos<lastat)
frm1.t3.focus();
else
return true;
</script>
</html>
--------------------------------------------------------------------------------------------------------------------------------------
CODE.HTML
<!DOCTYPE html>
<html>
<head>
<title>String function</title>
</head>
<body>
<form name="frm1">
</form>
</body>
<script type="text/javascript">
function cnt()
var s,i,ch,c;
c=0;
s=frm1.t1.value;
for(i=0;i<=s.length;i++)
ch=s.charAt(i);
if(ch=="A" || ch=="a" || ch=="E" || ch=="e" || ch=="T" || ch=="i" || ch=="O" || ch=="o"
|| ch=="U" || ch=="u")c++;
</script>
</html>
PALIMDOME.HTML
<!DOCTYPE html>
<html>
<head>
<title>Palindrome</title>
</head>
<body>
<form name="frm1">
</form>
</body>
<script type="text/javascript">
function chk()
var a,s,i,ch,n;
a=frm1.t1.value;
s=a.toLowerCase();
n=s.length;
var p=1;
for(i=0; i<n/2;i++)
if(s.charAt(i)!= s.charAt(n-1-i))
p=0;
break;
}
if(p==1)
alert("String is Palindrome");
else
alert("String is palindrome")
</script>
</html>
CELSIUS.HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<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").value* 9/5 +32;
document.getElementById("f").value = Math.round(x);
else
document.getElementById("c").value = Math.round(x);
</script>
</body>
</html>
GRADE.HTML
<html>
<body>
<form name="frm1">
Enter Marks of IT
</form>
</body>
<script type="text/javascript">
function grade()
{ var m1,m2,m3,m4,m5,a;
m1=frm1.t1.value;
m2=frm1.t2.value;
m3=frm1.t3.value;
m4=frm1.t4.value;
m5=frm1.t5.value;
a=(m1+m2+m3+m4+m5)/5;
if(a>90)
alert("Grade A");
else
if(a>=81)
alert("Grade B");
else
if(a>=71)
alert("Grade C");
else
{ if(a=61)
alert("Grade D");
else
alert("Grade F");
</script>
</html>
DATE.HTML
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
document.writeln(Math.round(difference_ms / one_day));
</script>
</head>
<body>
<form name="form_task">
</form>
</body>
</html>