Page 1 of 1

Saving value of check box

Posted: Mon Nov 17, 2008 10:16 pm
by mattiace
Sorry if this is in the wrong section.

I am designing a survey spread out over multiple pages and have alot of yes/no questions using radio buttons.
I want to be able to offer users to go back and change questions and at the same time keep there answer checked.
I did get it to work with alot of "if statements" but the code is messy and I have to apply it to every question. Is there a way to check a radio button based on a variable?

Re: Saving value of check box

Posted: Wed Nov 19, 2008 8:45 am
by it2051229
yes... try naming all the checkboxes with the same name and by the time you CATCH the values using PHP code that is automatically an ARRAY.

Re: Saving value of check box

Posted: Wed Nov 19, 2008 9:01 am
by aceconcepts
However, when you rename all the checkbox elements, also add an opening and closing set of square brackets after its name e.g.:

Code: Select all

<input type="checkbox" name="check1[]" />
The square brackets tells PHP that this element is being passed as an array.