I was wondering how I could input a value into a form with html. So right when the user goes to the site there\'s numbers in the text boxes already and they use those number
To have numbers in input fields you can set them to have a value, like value="10"
and the default value would be 10 until the user changes it.
<input type="text" id="answer" value="5" >
or
document.getElementById("answer").value = "5";
well you can put this script after the form is created:
<form name="addition" action="" method="get">
<table border="1">
<tr>
<td>Value 1:</td> <td><input type="text" name="value1" id="value1"/></td>
</tr>
<tr>
<td>Value 2:</td> <td><input type="text" name="value2" id="value2"/></td>
</tr>
<tr>
<td>Answer:</td> <td><input type="text" id="answer" /></td>
</tr>
<tr><td><input type="button" value="Submit" onClick="addSubmit()" id="submit" /></td><td><input type="button" value="Give Up" onClick="addGiveUp()" /></td></tr>
</table>
</form>
<!-- This is the script-->
<script type="text/javascript">
document.getElementById("value1").value = Math.floor(89+Math.random()*11);
document.getElementById("value2").value = Math.floor(89+Math.random()*11);
</script>
That would generate random numbers for you and put them in the form See here for the code: http://jsfiddle.net/wVAFt/