开发者

codeigniter form_radio problem

开发者 https://www.devze.com 2023-02-02 15:08 出处:网络
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

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'); ?> 
0

精彩评论

暂无评论...
验证码 换一张
取 消