Page 1 of 1

Relating fields to eachother.

Posted: Mon Feb 15, 2010 3:16 pm
by 283Banfil
Second question in one day!!

I want a field mandatory if the user has answered yes to a prior field. but is not mandatory if they answered no.

For example:

Yes- I have kids

How many? mandatory if they answer yes to above question.

Re: Relating fields to eachother.

Posted: Mon Feb 15, 2010 4:34 pm
by Christopher
You can do this with Javascript for a single page solution, or use PHP to check submitted values and either add the field or ask for it on an additional page.

Re: Relating fields to eachother.

Posted: Mon Feb 15, 2010 10:10 pm
by xjake88x
This can be dealt with many ways. One approach would be to generate an array of which fields are required.

Code: Select all

 
if($has_kids) $required_fields[] = 'kid_count';
 
Then later when checking required fields, you can easily loop through the array.