Page 329 - Web Applications (803) Class 11
P. 329
<P style="color:blue;">
<SCRIPT>
var num=parseInt(prompt("Enter a number"));
for (i = 2; i <= num; i+=2) {
document.write(i+"<BR><BR>"); }
</SCRIPT>
</P>
</BODY>
</HTML>
Output:
When you click on the “OK” button, with the message “This page says”. Then a new windows appears as shown below:
Example:
<HTML>
<BODY text=”green”>
<h2> program to accept a number and display its factorial </H2>
<P style="color:blue;">
<script>
var num=parseInt(prompt("Enter a number"));
var fact=1
for (i = num; i > 0; i--) {
fact=fact*i; }
document.write("The factorial of "+num+" is "+fact);
Introduction to Dynamic Websites Using JavaScript 327

