Field calculation
-
Xnau, I followd this support thread https://www.ads-software.com/support/topic/update-only-one-field?replies=5
I have one field(balance) that should be calculated from the difference of two other fields (to_pay – amount_paid) (when the form is filled on the backend)
SO i edited the code you provided in the thread and placed it in /templates/pdb-record-default.php line 8.<script type="text/javascript"> // this is the standard wrappper for jQuery functions in WP jQuery(document).ready(function($) { // attach a function to the submit button click $('.pdb-record form .pdb-submit').click(function () { // calculate the difference of two fields var difference = (parseInt($('input[name=to_pay]').val()) - parseInt($('input[name=amount_paid]').val()) ); // set the value of the balance field $('input[name=balance]').val(difference); // now submit the data $('.pdb-record form').submit(); // this is so the browser won't submit it also. return false; }); }); </script>
What am I not getting right here, is it the code or where(file or line) I should put it or anything else?
Thank you.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Field calculation’ is closed to new replies.