Re: Retrieve values from checkboxes

From: Date: Mon, 24 Mar 2003 16:14:56 +0000
Subject: Re: Retrieve values from checkboxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-140853@lists.php.net to get a copy of this message
On Mon, 24 Mar 2003 13:06:45 -0000, Shaun <shaun@mania.plus.com> wrote:
Hi, I have some checkboxes on my form and am using the following code to populate it. The box will be checked if the user is allocated to the project. My problem is if I uncheck a checkbox and send the form I don't know what the $project_id is as it returns zero, so I cant delete the corresponding record, is there a way around this? while($j < $num){ $project_id = mysql_result($result, $j, Project_ID); $project_name = mysql_result($result, $j, Project_Name); echo '<tr> <td height="30">'.$project_name.':</td> <td><input name="'.$project_id.'" type="hidden" value="0"> <input name="'.$project_id.'" type="checkbox" value="'.$project_id.'" '; $k = 0; while ($k < $num_elements){ if ($project_id == $project_id2[$k]){ echo 'checked'; } $k++; } echo '></td> </tr>'; $j++; }
No. Checkboxes *only* send information if they've been checked. You might want to consider using a radio input instead and forcing one to be defaulted (for a short list of options) or a select box (for a long list of options). -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

« previous php.general (#140853) next »