radio

本文详细介绍了Struts框架中Radio标签的使用方法及其属性设置,包括如何通过value属性设定默认选中的选项,以及如何配合JavaScript实现动态交互效果。
<script type="text/javascript">
function test(val){

if(val=='first'){
document.forms[0].firstfield.disabled = true;
document.forms[0].secondfield.disabled = false;
}else{
document.forms[0].firstfield.disabled = false;
document.forms[0].secondfield.disabled = true;
}
}
</script>
<s:radio name="'hello'" list="{'first','second'}" onclick="test(this.value)" theme="simple"/>

<s:textfield name="testbean.firststr" id="firstfield" maxlength="6" size="10" theme="simple"/>
<s:textfield name="testbean.secondstr" id="secondfield" maxlength="6" size="10" theme="simple"/>


radio标签是用来做单选效果的.

最基本的radio:


<s:radio name="'sex'" label="%{getText('user.sex')}" list="{'male','female'}"/>

以下是标签文件模板的一部分代码

<input
type="radio"
#if( $tag.contains($parameters.nameValue, $itemKey) )checked="checked"#end
#if ($parameters.name)
name="$!struts.htmlEncode($parameters.name)"
id="$!struts.htmlEncode($parameters.name)$!struts.htmlEncode($itemKey)"
#end



有个checked="checked",他的意思就是说这个默认值可以用name或value来指定.如果你已经用了name,那么可以用value来给值,value=哪个radio的value的话,那么这个radio就是checked了.
<s:radio list='#{1:"Head",2:"Fan",3:"Ins"}' name="LoginType" label="Select your LoginType please" value="3">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值