Jquery not pulling Unique Ids

Home Forums Quform WordPress Jquery not pulling Unique Ids

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #20000
    brabox
    Participant

    Hello,

    I am not sure if this is possible or not but i am trying to to use Quform with a simple code made in JS.

    The idea is to make a “calculator” that shows the results on the fly, no need to redirect to another page.

    The HTML and JS calculator you can view here -> http://naturalcoder.com/

    What i did was to make the quform front end with those 3 elements, Quantity, Weight and Weight (lbs or Kgs).

    I then added a HTML element on quform and added the RESULT (where it displays the result) in there.

    Then included the separate JS file in the header.php.

    In the JS file i got the Unique IDs of each element and pasted in the correct place ->

    <script>
                           function storageFee () {
                    var qnt = document.getElementByname('.iphorm_24_3').value;
                    var weight = document.getElementByname('.iphorm_24_4').value;
                    var unit = document.getElementByname('.iphorm_24_5').value;
                    var storageTotal = 0 .toFixed(2);
                    var storageMessage;
    
                        if(qnt * weight == 0) { // if quantity or weight is equal to 0
                            storageMessage = " * Todos os campos precisam ser preenchidos! *";
                            storageTotal = 0;
    
                        } else if (qnt < 0 || weight < 0) { // if quantity or weight is negative
                            storageMessage = " * Apenas valores positivos são aceitos *";
                            storageTotal = 0;
    
                        } else if ((qnt % 1) > 0) { // if quantity is float
                            storageMessage = " * Quantidade de caixas deve ser número inteiro *";
                            storageTotal = 0;
    
                        } else if (qnt * weight > 0) { // if quantity and weight is positive
                            storageMessage = " * Valor por mês para itens recebidos no mesmo dia *";
    
                            if (unit == 'lbs') { // if unit is pounds
    
                                if (qnt * weight >= 20) { // if total weight is over 20 pounds
                                    storageTotal = (qnt * weight) * 0.50;
    
                                } else { // if total weight is under 20 pounds
                                    storageTotal = 10.00;
    
                                }
    
                            } else if (unit == 'kgs') { // if unit is kilos
    
                                if (qnt * (weight * 2.20462) >= 20) { // if total weight is over 20 pounds
                                    storageTotal = (qnt * (weight * 2.20462)) * 0.50;
    
                                } else { // if total weight is under 20 pounds
                                    storageTotal = 10.00;
    
                                }
                            }
    
                        }
    
                    storageTotal = storageTotal.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                    storageMessage = storageMessage.toString();
                    document.getElementByid('storageTotal').innerHTML = "Total = $" + storageTotal;
                    document.getElementByid('storageMessage').innerHTML = storageMessage;
                }
    </script>

    As you can see in the biggining -> var qnt = document.getElementByname(‘.iphorm_24_3’).value;
    var weight = document.getElementByname(‘.iphorm_24_4’).value;
    var unit = document.getElementByname(‘.iphorm_24_5’).value;

    But i guess the values are not pulling.

    Is this possible to accomplish?

    Thank you,
    Marco

    #20030
    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.

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