Automatically select box based on entered amount
-
Hi all,
Is there a way that when someone enters a number into the ‘Height’ box it automatically checks the correct height in the ‘Height band’
Ie someone enters 2100 it will automatically check ‘upto 2200’ or if someone enters 2512 it would automatically check ‘upto 2600’.
Hope this makes sense.
Thanks
Ben
The page I need help with: [log in to see the link]
-
Hello @benh123
Thank you very much for using our plugin. I need you to describe the rule you want to apply because you included two examples only in your entry.
The solution would be to insert an “HTML Field” in the form, with a content similar to:
<script> jQuery(document).on('change', '[id*="fieldname4_"]', function(){ if(typeof field_flag != 'undefined'){delete field_flag; return;} field_flag = true; var value = this.value; // Apply the rule that modifies the value jQuery(this).val(value).change(); }); </script>In the previous code, you should replace “// Apply the rule that modifies the value” with the code that modifies the field’s value.
Best regards.
Hi,
Thanks for your response.
So what I want to do is as follows:
When a user enters a size in millimetres (example 2188) it would automatically check the box ‘upto 2200’.
Hope this makes sense.
Thanks,
Ben
Hello @benh123
If you want to round up the number to the next multiple of 100, you should replace
// Apply the rule that modifies the valuein the code I sent you previously with:value = CEIL(value, 100);Best regards.
Sorry i’m not sure if you are understanding what i mean.
I have a ‘height’ field – when a user enters a number in there (example 2100) i want it to tick the ‘height band’ box relevant to the size they placed in the ‘height’ box if that makes sense?
Example – user enters 2595 in ‘height box’ then it will automatically tick ‘upto 2600’ in the height band?
Hope that makes sense and thank you for your prompt responses.
Ben
Hello @benh123
I’m sorry, I understand you now. But I still need you to describe the rules. For example, if the user enters any value lower than XYZ, then select the AAAA choice. If the user enters any value between XYZ and ABC then select the BBB choice, and so on.
In the previous entries, you escribed specific examples, but not rules we can implement.
Best regards.
Ok hopefully this clears it up.
If a user enters any number between:
1000-2200 – Checks box upto 2200
2201-2400 – Checks box upto 2400
2401-2600 – Checks box upto 2600Does that make sense?
Hello @benh123
In this case, the piece of code in the “HTML Content” field can be implemented as follows:
<script> jQuery(document).on('change', '[id*="fieldname4_"]', function(){ var value = this.value; if(value <= 2200){ jQuery('[id*="fieldname58_"][vt*="2200"]').prop('checked', true).change(); return;} if(value <= 2400){ jQuery('[id*="fieldname58_"][vt*="2400"]').prop('checked', true).change(); return;} jQuery('[id*="fieldname58_"][vt*="2600"]').prop('checked', true).change(); }); </script>Best regards.
Thank you!
That’s now working but i need it to only select one if the size changes, is there a way for it to clear the checked boxes if the height changes?
Thanks,
Hello @benh123
Yes, into the block of code you can include the following piece of code before the conditional statements:
jQuery('[id*="fieldname58_"]').prop('checked', false);Please, note that the support service does not cover the implementation of the users’ projects. If you need someone that implement your form, you can contact us directly through the plugin’s website:
https://cff.dwbooster.com/customization
Best regards.
Sorry where would i put it?
I put it before the if statements but now the code doesnt work?
Thanks,
Hello @benh123
Another alternative would be to untick the choices on the keyup event. You can insert another “HMTL Content” field in the form and enter the code:
<script> jQuery(document).on('keyup', '[id*="fieldname4_"]', function(){ jQuery('[id*="fieldname58_"]').prop('checked', false).change(); }); </script>Best regards.
Perfect that worked perfectly!
2 last questions I promise 🙂
Is there way to generate a random number (to be used as a quotation I.D) like maybe a 4 or 5 digit number thats different every time the page is loaded?
Last thing – is there a button i can add (on free version) to download the quote as a pdf? I know i can print to pdf but would prefer a download button if possible.
Thanks again!
Ben
Sorry 1 last thing – with the measurements on the ‘height’ & ‘width’ is there anyway to add ‘mm’ after the measurement – example the user enters 2200 but it shows as 2200mm.
Thank you again.
Hello @benh123
If you want to generate a PDF file with the information collected by the form, you will need the “PDF Generator” add-on distributed with the Platinum plugin version:
https://cff.dwbooster.com/blog/2020/07/19/pdf-generator
The alternative with the Free plugin distribution would be to insert a button field in the form and select the “Print Form” as its type.
To generate a number in the form, you can insert a calculated field in the form, and enter the following piece of code as its equation:
floor(random() * (99999 - 10000 + 1)) + 10000;Note that after submission the plugin generates a unique id to identify the data, and you can insert it into the notification emails, thank you pages, and PDF files by entering the tag
<%itemnumber length={{5}}%>More information in the following link:
https://cff.dwbooster.com/documentation#special-tagsFinally, if you want the plugin to format dynamically the height and width fields values, emulate them with currency fields by entering the
mmas the currency and ticking the “Format dynamically” checkbox in their settings.Best regards.
The topic ‘Automatically select box based on entered amount’ is closed to new replies.