clarky101
Dec 6th 2007, 9:46 am
hi i need to insert an integer using math.random into the following code and name it aNumber which produces an integer in the range 1 to 12 but am not sure on how i go about completing this. any advice would be much appreciated.
<html>
<head>
<script language=javascript type="text/javascript">
document.writeln("<h1>Learning to Multiply Web Site</h1>");
function checkAnswer() {
value1 = document.forms[0].value1.value; // user dom to set value1 variable to value of
first input
value2 = document.forms[0].value2.value; // user dom to set value2 variable to value of
second input
answer = value1 * value2; // times 2 values
document.forms[0].result.value = answer; //set result field equal to answer variable.
}
</script>
</head>
<body>
<form name="myForm" id="myForm" action="">
<table border = "1">
<tr>
<td> What is</td>
<td><input name="value1" type="text" /></td>
</tr>
<tr>
<td>Multiplyed By</td>
<td><input name="value2" type="text" /></td>
</tr>
<tr>
<td>The answer is</td>
<td><input name = "result" type = "text" /></td>
</tr>
<td><input type= "button" value = "Check My Answer" onclick="checkAnswer()" /></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<script language=javascript type="text/javascript">
document.writeln("<h1>Learning to Multiply Web Site</h1>");
function checkAnswer() {
value1 = document.forms[0].value1.value; // user dom to set value1 variable to value of
first input
value2 = document.forms[0].value2.value; // user dom to set value2 variable to value of
second input
answer = value1 * value2; // times 2 values
document.forms[0].result.value = answer; //set result field equal to answer variable.
}
</script>
</head>
<body>
<form name="myForm" id="myForm" action="">
<table border = "1">
<tr>
<td> What is</td>
<td><input name="value1" type="text" /></td>
</tr>
<tr>
<td>Multiplyed By</td>
<td><input name="value2" type="text" /></td>
</tr>
<tr>
<td>The answer is</td>
<td><input name = "result" type = "text" /></td>
</tr>
<td><input type= "button" value = "Check My Answer" onclick="checkAnswer()" /></td>
</tr>
</table>
</form>
</body>
</html>