I run a restaurant and what to be able to take inventory of how much I have in soft drink syrup for fountain drinks. I'm creating a dropdown to select the flavor, and have recorded the weight of a full container. I'll then weigh an open/partially dispensed unit, and its a simple math formula to figure out what is remaining, know these 2 figures. I am using Chris Adam's code to add large +/- buttons to record full units. Here is my problem: When I enter a weight amount in the partial weight field, it behaves correctly the and Total field updates. Updating the syrup flavor from the dropdown will also trigger the Total field to recalculate. However, when I use the +/- butons, the Total field isnt triggered/upddated. How can I make this work? https://connect.formidableforms.com/question/category/code-snippets/add-large-and-buttons-to-number-inputs/
I've dealt with this recently. When something is triggered programmatically you have to initiate a trigger on that programmed event before you can do something. I believe what I did was this.
$(selector).trigger("change"); //The field to watch changes for. Here selector should be the calculated field element ID
Then:
$(selector).on("change", function(){ //Here selector should be the calculated field element ID
//What to do here
});
< script > jQuery(".myNum").each(function () { var j = jQuery; //Just a variable for using jQuery without conflicts var addInput = (this); var n = 0; //n is equal to 0 //Set default value to n (n = 0) j(addInput).val(n); //On click add 1 to n j(this).next("span").on('click', function () { j(addInput).val(++n); j("#field_qb04u").trigger("change"); }) j(this).prev("span").on('click', function () { //If n is bigger or equal to 1 subtract 1 from n if (n >= 1) { j(addInput).val(--n); j("#field_qb04u").trigger("change"); } else { //Otherwise do nothing } }); }); </script>
I suggest removing the j(addInput).val(n); line and then setting the "Default Value" of field to 0 in the field settings.
Please login or Register to submit your answer
Can you provide a link to a live or test site showing the page?