Please help me add some random alerts to my code

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 24th, 2006, 01:04
New Member
Join Date: Nov 2006
Location: www
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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">&nbsp;</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>
Reply With Quote

Reply

Tags
help, add, random, alerts, code

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 19:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43