I have a repeater form where check names, and check amounts are entered, with the ability to add or remove check entries.
I can get this information via PHP easy enough and that works fine for emailing results. But attempting to calculate a sum of the checks via JavaScript prior to submitting is proving elusive. I need it to dynamically update the sum as new entries are typed, and if an entry is deleted. Are there any examples at all? Here is a segment of the generated code for the check amount:
I'm not a Javascript guru - PHP is more my strong suite. But JQuery does not seem to like the generated fields. However, I've yet to figure out how to code an onkeyup function that captures the value and sends a sum to another static field.
I can get this information via PHP easy enough and that works fine for emailing results. But attempting to calculate a sum of the checks via JavaScript prior to submitting is proving elusive. I need it to dynamically update the sum as new entries are typed, and if an entry is deleted. Are there any examples at all? Here is a segment of the generated code for the check amount:
I'm not a Javascript guru - PHP is more my strong suite. But JQuery does not seem to like the generated fields. However, I've yet to figure out how to code an onkeyup function that captures the value and sends a sum to another static field.
<input class="checkadd" onblur="if (this.value=='') this.value='0.00';" onfocus="if (this.value=='0.00') this.value='';" onkeyup="return calculateSum()" data-events="[]" placeholder="Amount" id="amount0" value="" name="checklista[0][checkamount]" type="text">
<input class="checkadd" onblur="if (this.value=='') this.value='0.00';" onfocus="if (this.value=='0.00') this.value='';" onkeyup="return calculateSum()" data-events="[]" placeholder="Amount" id="amount1" value="" name="checklista[1][checkamount]" type="text">
<input class="checkadd" onblur="if (this.value=='') this.value='0.00';" onfocus="if (this.value=='0.00') this.value='';" onkeyup="return calculateSum()" data-events="[]" placeholder="Amount" id="amount2" value="" name="checklista[2][checkamount]" type="text">
<input id="totalSum" type="text" class="form-control" name="totalSum">