Java Script


JavaScript Tutorial


Admission Enquiry Form


Print Compuhelp 10 times using for loop.

Example:

<html>
<head>
<title>Print compuhelp 10 times using for loop</title>
</head>

<body>
<script>
var i;
for(i=1;i<=10;i++)
{
document.write("Compuhelp <br> ");
}
</script>
</body>
</html>


Print Compuhelp according to number entered using prompt() by for loop.

Example:

<html>
<head>
<title>Print compuhelp according to number entered using prompt() by for loop</title>
</head>

<body>
<script>
var i,n;
n=parseInt(prompt("Enter how many times you want to print compuhelp"));
for(i=1;i<=n;i++)
{
document.write("Compuhelp <br> ");
}
</script>
</body>
</html>

Print Compuhelp on Button click using function by for loop.

Example:

<html>
<head>
<title>Print compuhelp on Button click using function by for loop</title>
<script>
function print_compuhelp()
{
var i,n;
n=parseInt(prompt("Enter how many times you want to print compuhelp"));
for(i=1;i<=n;i++)
{
document.write("Compuhelp <br> ");
}
}//end of function
</script>

</head>

<body>
<input type="button" value="click" onClick="print_compuhelp()">
</body>
</html>