加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

html:radio标签

(2012-07-16 21:39:43)
标签:

杂谈

html:radio标签生成一个radio。主要的用法有两种,下面我们通过代码来示例。

下面的代码示例了html:radio标签的一般用法,如果被提交则选中的radio的value值将被提交到radioForm中的id中。

<html:radio name="radioForm" property="id" value="00001">
     One
</html:radio>
<html:radio name="radioForm" property="id" value="00002">
     Two
</html:radio>
下面的代码示例了html:radio标签的典型用法,其中的persons和bean:define标签中的一致,您可以参考bean:define标签。我只介绍这个<html:radio idName="person" property="id" value="id">,idName指定html:radio要使用的bean(这里为person),value="id"表示person的id属性将作为radio元素的value值而property="id"表示提交时选中的radio的值将被提交给radioForm中的id属性。

<logic:notEmpty name="radioForm" property="persons"> 
     <logic:iterate id="person" name="radioForm" property="persons">
       <html:radio idName="person" property="id" value="id">
         <bean:write name="person" property="name"/>
       </html:radio>
     </logic:iterate> 
</logic:notEmpty>


文章出自: http://hi.baidu.com/tsredsun/blog/item/55dbf4af138d6dce7dd92a24.html

例如:
<html:radio idName=" idName "   value="value"   name=" name" property=" property " />
表示在输出时,html:radio输出为input type="radio";name输出为name="name";对于value的输出,当不指定idName时,value="value",当指定idName时,输出是由bean名为" idName ",属性名为"value"的属性值;当bean名为" name ",属性名为" property "的属性值等于上述value的输出值时,输出checked="checked"。 我的例子:
<logic:iterate
id = "answer"
name = "answerList"
scope = "page">
<html:radio idName = "answer" value = "answerItem" name = "question" property = "rightAnswer" ></html:radio>
</logic:iterate>

如果从bean answer的answerItem属性中取出的值等于从bean question的rightAnswer属性中取出的值相等,那么该radio将被选中

<input type="radio" id="${element.rowNum}" name="radiobutton${element.rowNum}" value="true" checked ="true" onclick="addRadioValue(this.id,this.value)">&nbsp;是

想要默认选中, 在Form中赋值就可以了.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有