Hello i want to use the form_radio in codeigniter, and i want the first to be sele开发者_Go百科cted, but how can i do that ?, i have this now
<div style="float:left;">Dreng:</div> <?php echo form_radio('dreng', '1', true, 'class=radio'); ?>
<div style="float:left;">Pige:</div> <?php echo form_radio('pige', '2', false, 'class=radio'); ?>
You have to give it a reason to default to on. If you are calling this HTML on a create page, use the lack of $_POST as a sign to default.
<div style="float:left;">Dreng:</div> <?php echo form_radio('dreng', '1', empty($_POST), 'class=radio'); ?>
<div style="float:left;">Pige:</div> <?php echo form_radio('pige', '2', false, 'class=radio'); ?>
Are these two radio buttons belong to the same group? it sounds like they are! if so then you have to use the same name
field:
<div style="float:left;">Dreng:</div> <?php echo form_radio('group_name', '1', true, 'class=radio'); ?>
<div style="float:left;">Pige:</div> <?php echo form_radio('group_name', '2', false, 'class=radio'); ?>
精彩评论