Using form to create calculator

Home Forums Quform WordPress Using form to create calculator

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20721
    Leodore
    Participant

    Hi 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.
    #20734
    Ally
    Support Staff

    You 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.
    #20739
    Leodore
    Participant

    Thank you so much Ally!
    That works perfectly.

    Kind regards

    Leo

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy