日期:2014-05-17  浏览次数:20776 次

struts2.0中 如何动态控制<s:textfield>readonly 属性
<table align="center" width="60%"
style="color: #369; border: #92B0DD 1px solid; margin-top: 30px;"
id="tab">
<tr>
<td colspan="2" align="center"><%=request.getParameter("host")%><%=request.getParameter("zone")%></td>
</tr>
<tr>
<td class="bo_01">
在线设置:
</td>
<td class="bo_01">
<table id=OnlineOpt style="FONT-SIZE: 9pt" border=0>
<tbody>
<tr>
<td>
<input id="OnlineOpt_0" type="radio" checked value="0"
name="OnlineOpt" />

<label for="OnlineOpt_0">
解析到最新的IP上
</label>
</td>
<td>
<input id="OnlineOpt_1" type="radio" value="1"
name="OnlineOpt" />
<label for="OnlineOpt_1">
指定到静态IP上
</label>
</td>
<td>
<input id="OnlineOpt_2" type="radio" value="2"
name="OnlineOpt" />
<label for="OnlineOpt_2">
转发指定的网址
</label>
</td>
</tr>
</tbody>
</table>
&nbsp;&nbsp;静态IP:

<s:textfield id="OnlineIP" name="domain.data" readonly="true" ></s:textfield>
<br />
指定网址:
<s:textfield id="OnlineUrl" name="domain.data" readonly="true"></s:textfield>
</td>
</tr></table>
<script>

document.getElementById("OnlineOpt_0").onclick=function()
{
 document.getElementById("OnlineIP").readonly=true;
 document.getElementById("OnlineUrl").readonly=true;

}
document.getElementById("OnlineOpt_1").onclick=function()
{

 document.getElementById("OnlineIP").readonly="false";
 document.getElementById("OnlineIP").focus();
 document.getElementById("OnlineUrl").readonly="true";

}
document.getElementById("OnlineOpt_2").onclick=function()
{
document.getElementById("OnlineIP").readonly=true;
document.getElementById("OnlineUrl").readonly=false;
document.getElementById("OnlineUrl").focus();

}
</script>

------解决方案--------------------
Name Required Default Evaluated Type Description 
readonly false false false Boolean Whether the input is readonly
------解决方案--------------------
探讨
点击单选按钮,对应的文本框变为可写。struts2.0 中readonly只有一次有效吗?怎么解决这个问题?