This is my first project using JavaScript.
I have a PHP page that loads text fields "if" called for. I thought JavaScript would be a great way to get the total of all Text Fields without Submit.
The code below is an example of my problem.
<SCRIPT language = JavaScript>
function calculate() {
A = document.frmOne.txtFirstNumber.value *1
B = document.frmOne.txtSecondNumber.value *1
C = document.frmOne.txtThirdNumber.value *1
D = A + B + C
document.frmOne.txtFourthNumber.value = D
}
</SCRIPT>
<FORM NAME = frmOne>
Number One: <INPUT TYPE = Text NAME = txtFirstNumber SIZE = 5 value ="">
Number Two: <INPUT TYPE = Text NAME = txtSecondNumber SIZE = 5 value ="">
<P>
Total: <INPUT TYPE = Text NAME = txtFourthNumber SIZE = 5 value = "">
<P>
<Input Type = Button NAME = b1 VALUE = "Add Numbers" onClick = calculate()>
</FORM>
If I add
<INPUT TYPE = Text NAME = txtThirdNumber SIZE = 5 value ="">
to the form, the code works fine.
But again my page dose not always call ALL the Fields in the JS code.
Can anyone help me with this?
Thanks