Home › Forums › Quform WordPress › Jquery not pulling Unique Ids
- This topic has 1 reply, 2 voices, and was last updated 7 years, 6 months ago by Ally.
- AuthorPosts
- September 27, 2016 at 7:45 pm #20000braboxParticipant
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,
MarcoSeptember 29, 2016 at 2:20 pm #20030AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.