Home › Forums › Quform WordPress › Using form to create calculator
- This topic has 2 replies, 2 voices, and was last updated 8 years, 7 months ago by
Leodore.
- AuthorPosts
- January 29, 2017 at 3:45 pm #20721
Leodore
ParticipantHi Ally,
I was wondering how to go about this problem. I have a number and it can be altered either by a number entered into a text field or it can be altered by selecting a different number from a drop down list.I have managed to get the form to work so far using jquery that each time the text input is altered the number changes, however if I then change the drop down list I can’t get the number to alter further
'<input type="hidden" name="m_d_s" id = "mds" value="1000000" /> <script> Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }; jQuery(document).ready(function ($) { $(".iphorm_24_4").on('keyup',function(){ var emdts = $('.iphorm_24_18').change('option:selected').val(); var thismuch= $("#mds").val() / emdts /$(this).val() $(".this_much").html('$' + thismuch.formatMoney(2, '.', ',')); }) }); </script>'
in this code I need it so that if drop down iphorm 25_18 changes then emdts is automatically updated. Any help would be greatly appreciated
- This topic was modified 8 years, 7 months ago by
Leodore.
January 31, 2017 at 10:02 pm #20734Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 8 years, 7 months ago by
Ally.
February 1, 2017 at 12:41 am #20739Leodore
ParticipantThank you so much Ally!
That works perfectly.Kind regards
Leo
- This topic was modified 8 years, 7 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.