Hi chaps
I'm creating an intelligent form for my site. It basically generates form fields based on what was selected from the previous field so as to only show relevant questions. The form is sticky so it remembers inputs using the if(isset($_POST['var'])) to populate values when the form is submitted to itself.
I have a section which allows users to select multiple checkboxes to create an array. What I need to do is make this sticky so when the continue button is pressed the values ticked remain ticked. I've tried the code below but when submitted it checks all the boxes even if only one/some are checked initially.
Any help appreciated.
Cheers
echo '<input name="products[]" type="checkbox" value="books"';
if(isset($_POST['products']) AND $_POST['products'][]='books')
{
echo ' checked';
}
echo '>';
Making checkboxes sticky
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
if(isset($_POSTї'products']) && in_array('books', $_POSTї'products']))