Please Must answer this

+1 Rehan Asghar · June 27, 2015
How cam I get a number from user and save it in a variable using javascript ?
please try to answer in code !!!

Post a Reply

Replies

Oldest  Newest  Rating
0 Naeem Shakir · June 28, 2015
<!DOCTYPE html>
<html>
<body>

<p>Click the button to demonstrate the prompt box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var person = prompt("Please enter your name", "Harry Potter");
    
    if (person != null) {
        document.getElementById("demo").innerHTML =
        "Hello " + person + "! How are you today?";
    }
}
</script>

</body>
</html>
0 Rehan Asghar · July 17, 2015
@kayler & @Naeem ... Thanks to both of you for help
  • 1

Javascript

107,304 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators