...

View Full Version : Handle check Box



vikaspa
04-23-2004, 06:50 AM
I am sure this must have been answered but I tried to locate but could not get exact answer

1. I am reading a database table
2. Based on its value say $active = "Y"
3. I want to make the check box checked
if $acive="Y" then make the check box checked
else
keep it unchecked
4. Also pass(to database) "Y" when the check box is checked and "N" otherwise..


Please help !!!

Thanks in advance

firepages
04-23-2004, 03:20 PM
if checked the variable $_REQUEST['chk']; will have a value on the receiving page , (check for <?if(!empty($_REQUEST['chk'])){/*etc*/}?>



<?
$CHK = ( $active=='Y' ) ? ' CHECKED' : '' ;
?>
<input type="checkbox" name="chk" value="<?=$active;?>"<?=$CHK;?> />


note that the above HTML is not valid though it will work , I think checked is now an attribute?.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum