This is a discussion on "Please help me add some random alerts to my code" within the JavaScript Forum section. This forum, and the thread "Please help me add some random alerts to my code are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Please help me add some random alerts to my code
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Please help me add some random alerts to my code
hello there,
Ive made the following to do simple maths multply, but i would like to add 4 more comments. if the user gets it correct or incorrect, 4 on each side and for the comments to be random, is what im after, Ive got this far, but im really new to javascript If anyone could help me i would be most grateful <html> <head> <script type="text/javascript"> function genQuestion() { var x = Math.floor(Math.random() * 13); var y = Math.floor(Math.random() * 13); document.getElementById("inputVal").innerHTML = + x +" x "+ y +"?"; document.getElementById("answer").value = x * y; document.getElementById("outputVal").value = ""; } function buttonPressed() { if(document.getElementById("outputVal").value == document.getElementById("answer").value) { alert("Correct - Well Done!! "); genQuestion(); } else { alert("Wrong - Please try again!"); document.getElementById("outputVal").value = ""; } } </script> </head> <body onLoad="genQuestion();"> <h1>Learning to Multiply Web Site</h1> <form name="myForm" id="myForm" action=""> <input type="hidden" name="answer" id="answer" value="" /> <table border="1"> <tr> <td><b>What is :</b></td> <td><div id="inputVal"> </div></td> </tr> <tr> <td><b>The Answer is:</b></td> <td><input name="outputVal" id="outputVal" type="text" /></td> </tr> <tr> <td colspan="2" align="right"><input name="calculate" type="button" value="Check my Answer" onclick="buttonPressed()" /></td> </tr> </table> </form> </body> </html> |
|
|
![]() |
| Tags |
| help, add, random, alerts, code |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| live search code and styleswitcher code | hebel | JavaScript Forum | 0 | May 12th, 2007 06:16 |
| Alerts: Only one wanted - How to? | jswebdev | JavaScript Forum | 4 | Dec 17th, 2006 21:03 |
| Can somebody give me the code to hide the source code? | renren | JavaScript Forum | 7 | Mar 7th, 2006 12:27 |
| Else and alerts | chuckcampbell | JavaScript Forum | 8 | Oct 5th, 2005 18:44 |
| random | benbramz | Classic ASP | 5 | Jul 18th, 2005 05:01 |