如何设置单选按钮的值编辑时? [英] How to set the value for Radio Buttons When edit?
本文介绍了如何设置单选按钮的值编辑时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个男性和男性单选按钮,女。当我第一次注册时,单选按钮的值将存储在数据库中。现在我的问题是,如果我再次编辑该行,它希望来(这意味着检查)与该值作为男性/女性。如何做到这一点?
注意:用php做。
HTML Script:
< tr id =inside>
< td align =rightwidth =40%id =side>性别< / td>
< td width =3%> < / TD>
< td align =leftwidth =50%>
< input type =radioname =sexvalue =Malesize =17> Male
< input type =radioname =sexvalue =女性size =17>女性
< / td>
< / tr>
解决方案
当您填充字段时,可以检查值:
< input type =radioname =sexvalue =Male<?php echo $ sex $'male')?'checked':''?> size =17> Male
< input type =radioname =sexvalue =Female< ?php echo($ sex =='Female')?'checked':''?> size =17>女性
假设您从数据库中返回的值位于变量中 $ sex
checked选项将预先选择匹配的值
I have a Gender Row with radio buttons male & female. when i register as first time the values of radio button will store in database. Now my question is if i edit that row again it want to come(that means checked) with that value as male/female. how to make it?
Note : Doing with php.
HTML Script :
<tr id="inside">
<td align="right" width="40%" id="side" >Gender</td>
<td width="3%"> </td>
<td align="left" width="50%">
<input type="radio" name="sex" value="Male" size="17">Male
<input type="radio" name="sex" value="Female" size="17">Female
</td>
</tr>
解决方案
When you populate your fields, you can check for the value:
<input type="radio" name="sex" value="Male" <?php echo ($sex=='Male')?'checked':'' ?>size="17">Male
<input type="radio" name="sex" value="Female" <?php echo ($sex=='Female')?'checked':'' ?> size="17">Female
Assuming that the value you return from your database is in the variable $sex
The checked property will preselect the value that match
这篇关于如何设置单选按钮的值编辑时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文