- jotformhalalcateringsgAsked on August 04, 2012 at 10:02 PM
I need a field to give the total amount of another 2 fields.
E.g. field1 = 4 qty, field2 = 6 qty,
total will show 10 qty.
I have checked grading tool, it does not provide what i need.
- JotForm SupportabajanAnswered on August 04, 2012 at 10:16 PM
Is there a form in your account with such fields already in place? If so, please provide its name so that our team can examine it and provide solutions appropriate for that form.
- jotformhalalcateringsgAnswered on August 04, 2012 at 10:25 PM
You may look at http://www.jotform.com/?formID=21521271373445
I need a field that is able to give the total quantity of bento ordered.
say chicken briyani = 4, mutton briyani =6, Total = 10.
- JotForm SupportidarktechAnswered on August 05, 2012 at 01:40 AM
2. After cloning this form, get the form source code and paste it to notepad or any other text/html editing tool you have.
a = eval(document.getElementById("input_17").value)
b = eval(document.getElementById("input_18").value)
c = (a+b)
document.getElementById("input_26").value = c
document.getElementById("input_26").value = '0';//or a message of your choice
See how it looks like here.
4. Now to make the above code works, you have to insert onchange = compute() event to the input code of the two fields which are Chicken Briyani Bento id="input_17" and Mutton Briyani Bento id="input_18". Just search for this highlighted field ID's on your form source code and append onchange = compute() next to it.
Check this screen for a guide:
Also, to make your total field uneditable, simply paste this code at the bottom part of your form source code. After </form> tag.
5. Embed your form source code or you may save it as html file.
See it in action here: http://idarktech.com/test_calculation.html
Hope this helps. Let us know if you require assistance with this. Thanks!
- WendyyeoAnswered on August 05, 2012 at 03:53 AM
Thank you for the detailed instructions. I managed to insert the source codes up to step 4. Now, how do I embed my form source code ?
- JotForm SupportabajanAnswered on August 05, 2012 at 04:32 PM
If you wish the total to be updated not only when the arrows in the Chicken Briyani Bento and Mutton Briyani Bento boxes are clicked but also when the numbers are typed in via the keyboard, as will be necessary with some browsers, don't make any changes to the copy of the form's source obtained from the Embed Form Wizard. Just embed it as is and append this code to it, as you'll see in the source of this page.
Anyway, do let us know if you have a website in which to embed the form's source because regardless of what we eventually come up with, that will certainly be a requirement.
- JotForm SupportabajanAnswered on August 05, 2012 at 06:15 PM
If using my solution, this shorter code can be substituted for the longer version. But there's still the browser issue to be dealt with. Further testing has shown it not to be as serious as I initially thought because upon submission the Total box is populated with the correct value and that value is displayed in both the form's notification and submission records. But if possible, the code should still be edited for consistency across browsers.
- JotForm SupportabajanAnswered on August 06, 2012 at 11:09 AM
In order for the Total box's value to become un-editable in Internet Explorer 8 and below, the code that's added to the bottom of the form's source needs to be changed. Please update it to this.