Clear option in dropdown when its not viewable

Ask your questions here.
Post Reply
odraregmx
Posts: 100
Joined: 15 Oct 2016, 14:26
Name: Gerardo Alvarez
Location: Mexico City
Company Name: Fuga Espacio Alternativo
Contact:

Clear option in dropdown when its not viewable

Post by odraregmx »

Hi you all rukos fellas, hope you are doing ok
Here i am again asking for your advice.

I have a form to register assistants to an event, i have extension and published the form using Public Forms.

I have to determine the cost of the registration based on the quantity off assitants (base cost) and the extra nights they will be in place (additional cost) the sum of this two options will give me the total cost of the registration.

So i have a dropdown field based in a global list for assitants and several dropdown fields for each one of the assistants options, wich i show or hide depending of the user selection in the field assistants using Display field rules.

This an brief example

Dropdown 1 - Assitants - Based on a Global list with values for each option
- 1 adult (value 10)
- 1 adult + 1 child (value 15)
- 1 adult + 2 childs (value 20)

Dropdown 2 - Extra nights for 1 adult - Based on a Global list with values for each option
- 1 Nigth (value 3)
- 2 Night (value 6)
- 3 Night (value 9)

Dropdown 3 - Extra nights for 1 adult + 1 child - Based on a Global list with values for each option
- 1 Nigth (value 5)
- 2 Night (value 10)
- 3 Night (value 15)

Dropdown 4 - Extra nights for 1 adult + 2 childs - Based on a Global list with values for each option
- 1 Nigth (value 10)
- 2 Night (value 20)
- 3 Night (value 30)

So when the registrer select in the Assistants field the option 1 adult, that will show the field Extra nights for 1 adult, if he select the option 1 adult + 1 child, that will show the field Extra nights for 1 adult + 1 child and hide any other fields of extra nights.

Then with a MySQL formula field i sum the value of the fields and show it at the end of the registration calling the total field id in the Successful sending message block. To here everything seems to be fine.

The problem that i am facing is when someone select at first 1 adult and 1 extra night, and then changes his mind and select 1 adult + 1 child and 1 extra night, the value of the 1 extra night for 1 adult that he made previous, remains selected an the value is added to the sum.

What i am doing at the time is, check wich option was his fisrt and deselect the extra nights options for thar previos selection.

Can you advice on how can i manage to clear any previous selection of the fields extra night and just sum the values for the defenitly selected options?

Thanks in advance for your attention
Post Reply