I have not found an answer to this online nor does the debugger tell me enough to understand what alternatives I might use. Is it possible to post the “fill” value into the text boxes using an array to the effect I’m trying to use below? I could write document.form.a.value = fill; document.form.b.value = fill; etc., but a loop and array seems more more simplified and efficient.
Here’s a simplified version of the code that’s giving me an error:
<script type="text/javascript">
function postData() {
var fill = 0.0;
var txtBoxLetter = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
for (var i = 0; i < txtBoxLetter.length; i++) {
document.form.txtBoxLetter[i].value = fill; // Error on this line
}
}
</script>
<form name="form" method="" action="">
<input type="text" name="a" size="1" readonly="true">
<input type="text" name="b" size="1" readonly="true">
<input type="text" name="c" size="1" readonly="true">
<input type="text" name="d" size="1" readonly="true">
<input type="text" name="e" size="1" readonly="true">
<input type="text" name="f" size="1" readonly="true">
<input type="text" name="g" size="1" readonly="true">
<input type="text" name="h" size="1" readonly="true">
// etc.
</form>
Thanks for the help!
MDN form elements