Html 选择OneRadio并禁用inputText
这是我的html代码Html 选择OneRadio并禁用inputText,html,jsf,jsf-2,facelets,Html,Jsf,Jsf 2,Facelets,这是我的html代码 <table > <tr> <th rowspan="3"> <h:selectOneRadio layout="pageDirection" onClick="alert('selam')" id="selectOneRadio">
<table >
<tr>
<th rowspan="3">
<h:selectOneRadio layout="pageDirection"
onClick="alert('selam')" id="selectOneRadio">
<f:selectItem itemValue="Categori" itemLabel="Radio 1" />
<f:selectItem itemValue="Service" itemLabel="Radio 2" />
<f:selectItem itemValue="Follower" itemLabel="Radio 3" />
</h:selectOneRadio>
</th>
<td>
<h:inputText value="inputText 1" />
</td>
</tr>
<tr>
<td>
<h:inputText value="inputText 2" />
</td>
</tr>
<tr>
<td>
<h:inputText value="inputText 3" />
</td>
</tr>
</table>
我想选择一个单选按钮。当我点击其中一个时,我希望输入文本被禁用
例如:
- 如果我单击收音机1,则输入文本1将被禁用
- 如果我单击收音机2,则输入文本2将被禁用
- 如果我单击收音机3,则输入文本3将被禁用
我该怎么做呢?看看这个,我想这就是你要找的
<html>
<head>
<script type="text/javascript">
function enable_area(opt)
{
//get the required document element and disable corresponding element.
document.form.textarea1.disabled = (opt == 'Categori' ? true : false);
document.form.textarea2.disabled = (opt == 'service' ? true : false);
document.form.textarea3.disabled = (opt == 'Follower' ? true : false);
}
</script>
</head>
<body>
<form action="" method="post" name="form">
<!--Pass the value field as selector when clicked on radio button-->
Radio1 <input type="radio" name="radio" value="Categori" onclick="enable_area(this.value);" />
<textarea name="textarea1"></textarea>
<br />
Radio2 <input type="radio" name="radio" value="service" onclick="enable_area(this.value);" />
<textarea name="textarea2"></textarea>
<br />
Radio3 <input type="radio" name="radio" value="Follower" onclick="enable_area(this.value);" />
<textarea name="textarea3"></textarea>
</form>
</body>
</html>
功能启用区域(opt)
{
//获取所需的文档元素并禁用相应的元素。
document.form.textarea1.disabled=(opt=='category'?true:false);
document.form.textarea2.disabled=(opt==“服务”?true:false);
document.form.textarea3.disabled=(opt=‘Follower’?true:false);
}
无线电1
无线电2
无线电3
将单选按钮值绑定到托管bean属性,并在单选按钮更改时使用
发送ajax请求和更新视图的部分内容,并根据所选单选按钮项值使用disabled
属性禁用
例如
与
@ManagedBean
@视域
公共类Bean{
私人弦乐电台;
私有字符串输入1;
私有字符串输入2;
私有字符串输入3;
// ...
}