|
Posted by Chung Leong on 03/11/06 06:34
I do something similiar. For added flexibility, I pass the field value
instead of the index into $_POST. I also have the function perform the
echo.
Here's the equivalent for checkboxes and radio buttons:
function checked($current_value, $item_value) {
if(is_array($current_value)) {
$checked = in_array($item_value, $current_value);
}
else {
$checked = ($current_value == $item_value);
}
if($checked) {
echo "checked";
}
}
<input type="checkbox" <? checked($ck, 'hello') ?> name="ck[]"
value="hello">
Navigation:
[Reply to this message]
|