Forums

Change Field Value Based on Other Field Selection

neowurkz 31 Mar, 2015
Hi All,

N00b here. πŸ˜€

I am trying to create a form where there are multiple subsections. Each subsection have multiple questions.
What im gunning for is to have a score for each subsection. The scoring is an "OR" proposition kind of thing. If one of the questions is incorrect, the entire subsection score should be 0.

Also at the bottom of the form, I am looking at including a "Total" field which is based on straightforward sum of the subsection scores.

I just managed to create the fields so far. I am at a loss on where to put the conditions within the form and how to go about it. Also, is there a way to show the subsection score and total in a real-time manner? If there are PHP or JQuery code involved, please help to point me in the right direction on where to place them. As I said, complete n00b here.πŸ˜€

Thank you in advance for your help!
GreyHead 31 Mar, 2015
Hi neowurkz,

To have the results shown 'live' then the calculation code needs to be written using JavaScript (probably using the jQuery library) and it goes into a Load JavaScript action in the On Load event of your form.

The JavaScript won't be terribly difficult but it's not a quick two line task either.

In general JavaScript is not completely secure so you should also check any important calculations after the form is submitted. This is done with PHP in a Custom Code action in the On Submit event of your form.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger