Ok. Take a simple script like this:
<script language="JavaScript">
<!--
function RunningTotal(form) {
a=eval(form.number1.value)
b=eval(form.number2.value)
RunningTotal=a+b
form.total.value=RunningTotal
}
//-->
</script>
<form>
<input name="number1" type="text" value="10" size="5" maxlength="4" onChange="RunningTotal(this.form)"> +
<input name="number2" type="text" value="20" size="5" maxlength="4" onChange="RunningTotal(this.form)"> =
<input name="total" type="text" value="30" size="6" maxlength="5">
</form>
I have to integrate this into a php/MySql based website that pulls the number of integers that need to be added from a db and the numbers that need to be added. Sure, the math can be done on the back end; but we want the running total to be dynamically calculated because we're allowing the user to change the values of number1, number2, etc. if need be.
So, let's say that x is the number of integers that need to be added. Let's say i is the actual count (so the variable for the input name would actually be "number"+$i;.) How do I use a for else statement to keep a running total until i > x?
Dispensing quality rants and mishaps since 1999:
<script language="JavaScript">
<!--
function RunningTotal(form) {
a=eval(form.number1.value)
b=eval(form.number2.value)
RunningTotal=a+b
form.total.value=RunningTotal
}
//-->
</script>
<form>
<input name="number1" type="text" value="10" size="5" maxlength="4" onChange="RunningTotal(this.form)"> +
<input name="number2" type="text" value="20" size="5" maxlength="4" onChange="RunningTotal(this.form)"> =
<input name="total" type="text" value="30" size="6" maxlength="5">
</form>
I have to integrate this into a php/MySql based website that pulls the number of integers that need to be added from a db and the numbers that need to be added. Sure, the math can be done on the back end; but we want the running total to be dynamically calculated because we're allowing the user to change the values of number1, number2, etc. if need be.
So, let's say that x is the number of integers that need to be added. Let's say i is the actual count (so the variable for the input name would actually be "number"+$i;.) How do I use a for else statement to keep a running total until i > x?
Dispensing quality rants and mishaps since 1999: