Checking Checkboxes

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
MathewByrne
Forum Commoner
Posts: 38
Joined: Sat Mar 27, 2004 9:49 pm
Location: Australia

Checking Checkboxes

Post by MathewByrne »

Hey,
I'm creating an online order form with a list of all products from a database. They all have checkboxes next to them:

Code: Select all

<input type="checkbox" name="item01"> Item 1
<input type="checkbox" name="item02"> Item 2
<input type="checkbox" name="item03"> Item 3
etc...
The form is posted to another page which I want to diplay all the checkboxes which are true. I know I have to loop through the items somehow, any ideas?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Make your checkboxes an array

Code: Select all

<?php
<input type="checkbox" name="item[]"> Item 1
<input type="checkbox" name="item[]"> Item 2
<input type="checkbox" name="item[]"> Item 3

?>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

(This topic should have been made in the 'Client Side' forum. This doesn't relate too much to PHP Code.)
Post Reply