Search Results

Search found 1 results on 1 pages for 'user1139403'.

Page 1/1 | 1 

  • Javascript for a prompt which accepts simple math as a value and then returns the answer

    - by user1139403
    I have written a snippet of code in javascript, for a prompt to appear when clicked. I want to be able to enter a simple math problem (i.e. 230/2) and have it output the answer, rather than the math problem I just entered. Your help will be much appreciated. <!DOCTYPE html> <html> <body> <button onclick="myFunction()">Click me</button> <p id="demo"></p> <script type="text/javascript"> function myFunction() { var x; var mathProblem=prompt("Enter your math problem",""); if (name!=null) { x = mathProblem; document.getElementById("demo").innerHTML = x; } } </script> </body> </html>

    Read the article

1