ASFWEB
ASFWEB
<html> <head> <script language="javascript"> function calc(form) { form.square.value=form.entry.value*form.entry.value form.cube.value=form.entry.value*form.entry.value*form.entry.value } </script> </head> <body onload="var name=prompt("enter your name",'name');alert("hi!"+name);"> <form method=post> enter a number:<input type="text" name="entry" value="" onchange="calc(this.form);"> <br> square of number entered:<input type="text" name="square" value="" onfocus="this.blur();"> <br> cube of number entered:<input type="text" name="cube" value="" onfocus="this.blur();"> </form> </body> </html>
HTML WITH JAVASCRIPT <html> <head> <script language="javascript"> function factorial(num) { var fact=1; if(num>1) { for(i=1;i<=num;i++) fact=fact*i; return fact } else { return fact; } } </script> </head> <body> <script> var input=prompt("enter a number","1"); var output=factorial(input); document.write("the factorial of"+input+"is"+output); </script> </body> </html>