Alert box
<html>
<head>
<script language="javascripts" type="text/javascript">
function show_alert()
{
alert("I am an alert box");
}
</script>
</head>
<body>
<form>
<input type="button" onclick="show_alert()" value="show alert box">
</form>
</body>
</html>
Loop continue
<html>
<title>loop continue </title>
<body>
<script language="javascripts" type="text/javascript">
for(var i=0;i<=10;i++)
{
if(i==5)
{
continue;
}
document.write("loop number is "+i)
document.write("<br/>")
}
</script>
</body>
</html>
Onforcus
<html>
<head>
<script language="javascripts" type="text/javascript">
function setStyle(x)
{
document.getElementById(x).style.background="yellow";
}
</script>
</head>
<body>
First name:<input type="text" onfocus="setStyle(this.id)"id="fname"/>
<br/>
last name:<input type="text" onfocus="setStyle(this.id)"id="lname"/>
</body>
</html>
Example function 2
<html>
<head>
<script language="javascripts" type="text/javascript">
function product(a,b)
{
return a*b;
}
</script>
</head>
<body>
<script language="javascripts" type="text/javascript">
document.write(product(3,4));
</script>
</body>
</html>
Example function 3 calculate
<html>
<head>
<script type="text/javascript">
function cal()
{
var num_1=parseInt(prompt("please enter number ","no 1"));
var c =prompt("please enter condition that you want to calculate");
var num_2=parseInt(prompt("please enter number","no 2"));
if(isNaN(num_1) || isNaN(num_2) || c=="")
{
alert("please type valid input");
}
else if(num_1!=null && num_2!=null)
{
if(c=="+")
{
var add= num_1 + num_2;
alert("adition is " + add);
}
else if(c=="-")
{
var sub=num_1 - num_2;
alert("subtraction is " +sub);
}
else if(c=="*")
{
var multi=num_1 * num_2;
alert("multiplication is "+multi);
}
}
}
</script>
</head>
<body>
<input type="button" onclick="cal()" value="cal"/>
</body>
</html>