我正在尝试用随机数填充文本框我目前正在一个文本框上尝试。在事件加载时,我希望文本框使用 javascript 填充随机数。
<script type="text/javascript">
function Random()
{
return Math.floor(Math.random() * 10);
}
</script>
<form name="f1">
a= <input type="text" name="field1" /></br>
b= <input type="text" name="field2" /></br>
Answer: <input type="text" name="ansfield" />
<input type="button" value="Fill" onload()="document.getElementById('field1').value=Random()"/>
</form>