Page 1 of 1

Checkbox - showing original values for update

Posted: Thu May 15, 2003 10:27 am
by jarow
I have an update form which displays the orginal values of the record being updated, i.e. it displays all the TEXT fields. I cannot get it to disply the original values of the checkboxes - either checked or unchecked.

I have looked around in the forums but can't find an answer. This one seems the most promising but can't get it to work.

Code: Select all

$checked=$row_rsupdate2['checkbox'];
echo "<input type='checkbox' name='AN'";
if ($checked==1){ 
echo " CHECKED>"; 
}else{ 
echo ">"; 
} ?>


The checkbox values in my database are 1 or 0. The value of the checkboxes on the original add record form was "checkbox"

any ideas on how I might show the original checkbox values on the update form?

many thanks

Jim

Posted: Thu May 15, 2003 11:07 am
by volka
you're sure $row_rsupdate2['checkbox'] exists and contains what you expect. Try a little debug code in there.

Code: Select all

$checked=$row_rsupdate2['checkbox'];
echo "<input type='checkbox' name='AN'";
if ($checked=='1'){
	echo " CHECKED />";
}elseif ($checked=='0'){
	echo ">";
}else{
	echo ' disabled="true" />';
}

Posted: Thu May 15, 2003 2:30 pm
by jarow
Thanks volka...you were right...checkbox didn't exist...I have now corrected it and it work fine...