# How to automatically insert a value to a field when an option on a previous field is selected?

• crb3024
Asked on November 20, 2014 at 11:02 AM

Hi there

What I am trying to achieve is a calculation of a value for payment based on:

Type of registration

Option a - 1 adult @ 6 GBP

Option b - 1 junior @ Free.

Option c - multiple on one form that can be adults only, juniors only or a mixture of both

Question 1

Calculations based on number of addults and number of children

scenario 1 - box for number of adults - if option a is selected, I am trying to get this box to automatically fill as 1 adult - so far not acheived and help needed please

scenario 2 - box for number of adults - if option b is selected, I am trying to get this box to automatically fill as 1 junior - so far not acheived and help needed please

scenario 3 - multiple registration form - this works OK and the value to pay uses the calculator to multiply the number of adults x 6 GBP and enters the total in the amount due box - no significant problems here but see below for an improvement that I would like to include and don't know if it can be achieved.

Question 2 re scenario 3 above

The multiple form (option c) at present will rely on the lead person manually completing the form correctly when entering the number of adults and the number of juniors.

The form uses the add row wizard to add extra horizontal rows for information about the each of participants being registered on the one form.  It would be very useful if the total number of adult entries and the number of junior entries listed could be entered in the respective boxes automatically based on the selection on each row on the grid.

The form is work-in-progress at present but I do need to publish it by embedding into a web page within the next few days.

Regards and thanks,

Chris

• Welvin
Answered on November 20, 2014 at 01:05 PM

Hi Chris,

#1. I think you can take advantage of our Update a form field value conditional logic. All instructions can be found to this guide: http://www.jotform.com/help/268-How-to-Insert-Text-or-Mathematical-Caculation-into-a-field-using-a-Condition.

So, based on the selection from the Dropdown field, update a value to a textbox field.

#2. It's the configurable list widget. Unfortunately, there's currently no way you can add the values in the widget to the calculation result so I'm afraid that the way you want it is not possible.

You can use your current method to just let them enter the value and include it in the calculation. You can use the conditional logic to update the value and make the result fields as Read-Only so someone can't edit it.

Please get back to us if you need further assistance.

Thank you!

• crb3024
Answered on November 21, 2014 at 07:50 AM

Hi Welvin

Many thanks, now sorted #1 but see #3 below.

Shame about #2 not possible, but at least the existing system works.

#3

The answer to Option a, scenario 1 produces a result of 06 instead of 6 in the "Total due" box.  When using Option c, scenario 3 the total due box (which automatically calculates based on the number of adults entered) does not show a lead 0 so 1 adult shows just 6.

Is this an unavoidable result of the conditional entry or is it something that I have done wrong that can be corrected?

Regards and thanks

Chris

• Welvin
Answered on November 21, 2014 at 09:39 AM

Hi Chris,

You are welcome.

#3. There's a slight issue to the way how you manage to calculate results. One is the "Total due £ (GBP)" field which is a Calculation widget. You have an existing calculation into this widget. And then you are trying to insert a value to it using the conditional logic which is a conflict.

You have to target plain textbox fields to the conditional calculation. Then use this plain textbox fields to the widget. I will clone your form and will try to correct it, then let you know here.

Thank you!

• crb3024
Answered on November 24, 2014 at 11:18 AM

Hi Welvin

Have you had any luck with trying to get the form to work?

Is my only other option to have a different form for multiple person registration? Would be a shame if I did have to do so and I am a little surprised that it would not be possible to run separate calculations based on separate circumstances.

Regards

Chris

• Welvin
Answered on November 24, 2014 at 11:52 AM

Hi Chris,

Please accept my sincere apologies! I have updated my form last week, but forgot to finish it. Thanks for reminding me here. My fault, I'm so sorry. I'm working on the form now and I'll let you know.

Thanks

• Welvin
Answered on November 24, 2014 at 12:10 PM

Here's the form, kindly review and tell me if this sounds good: http://www.jotformpro.com/form/43243785019962. I'll let you know the details after your confirmation.

Thank you!

• crb3024
Answered on November 24, 2014 at 12:55 PM

Hi Welvin

Looks as if you've cracked it thanks bar one point -

- the additional text box field which is meant to appear below the selection of charity/local community cause when the bottom "Other ......" line is selected is not appearing for all 3 options but I guess that's probably a bit of conditional formatting that's got lost and is easily reinserted.

I've tested embedding my form as it is into its intended position on the Web page and it's showing all fields all the time whereas it operates properly using the view option on Jotform, so I'll have to try again when the form is finalised to see if it's working properly when embedded.

Regards

Chris

• Welvin
Answered on November 24, 2014 at 01:49 PM

Hi Chris,

I've fixed the textbox field logic. Your conditional logic is set to "Hide" the field when the "other" option is NOT selected. It should be opposite, to use "Show" directly when it is selected.

As for embedding, please try using our iFrame method: http://www.jotform.com/help/148-Getting-the-Form-iFrame-Code. If there's still an issue, please open a new thread for that.

Thank you!

• crb3024
Answered on November 25, 2014 at 05:25 AM

Hi Welvin,

Oops - thanks  for correcting my error!

Can't see what you've done to correct the amount due field situation, so, as your version of the form works could you possibly add "OK" to the end of the form title and then copy it across to the list of forms on my account so that I can then copy the iFrame code then generated and paste into the destination page.

Hope you are not snowed in!!

Regards and thanks for all your assistance, it is very much apprecated,

Chris

• Welvin
Answered on November 25, 2014 at 08:10 AM

Hi Chris,

You can clone the form to your account by following this guide: https://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL.

For the details on how I corrected the form:

a. Added a calculation widget to the form that calculates the "One Adult Registration" which is 6GBP.

b. Re-configure your calculation for the Multiple Person Registration.

c. Added a calculation widget that calculates the total for both "Total for One Adult" and "Total for Multiple Person"

d. Added a conditional logic to the form to show either "Total for One Adult" and "Total for Multiple Person" when they are selected from the top dropdown field:

e. Paypal Payment is using the Grant Total:

Multiple revisions but all are easy to configure and add to the other forms you have. Please do not hesitate to get back to us if you need further assistance.

Thank you!

• crb3024
Answered on November 25, 2014 at 11:46 AM

Hi Welvin

A massive thanks for all the help.

I have successfully cloned your version page across and embedded with the iFrame code to get it working but there is a page length issue resulting so I have raised a new thread for that as you requested.

You have been a great help so thanks again.

Regards

Chris

• david
Answered on November 25, 2014 at 02:29 PM

On behalf of my colleague you are very welcome!  We should be able to get to your new ticket shortly.