You are here: irt.org | FAQ | JavaScript | Form | 6 | Q856 [ previous next ]
Try:
<script language="JavaScript"><!-- function calculate(what) { for (var i=1,answer=0;i<9;i++) answer += what.elements['textField' + i].value - 0; what.answer.value = answer; } //--></script> <form> <input type="text" name="textField1"><br> <input type="text" name="textField2"><br> <input type="text" name="textField3"><br> <input type="text" name="textField4"><br> <input type="text" name="textField5"><br> <input type="text" name="textField6"><br> <input type="text" name="textField7"><br> <input type="text" name="textField8"><br> <input type="text" name="answer"> <input type="button" value="Calcuate" onClick="calculate(this.form)"> </form>