August 14, 2009

Javascript 4: Prompt

prompt("What is your name?")
A popup will come up with a text box to type in your name.
Now let's add a variable to it:
var name prompt("What is your name?");
alert(name);
Lets Add more to it:
var name prompt("What is your name?");
alert("hello "+name);
This will now add a hello and then the name that you type in the site.

Let's add something new.
var num1=prompt("enter number 1");
var num2=prompt("enter number 2");
alert (num1*num2);
This will create a popup where you can multiple two numbers, any type of digit but only multiply. If you change the sign then it will go and solve that way in that operation.

No comments:

Post a Comment