一个的js 函数

来源:百度知道 编辑:UC知道 时间:2024/09/22 03:59:22
<form>

<input name="ra" id="01" type="radio" value="0" checked="checked"/>
<input name="ra" id="02" type="radio" value="1" />
<input name="ra" id="03" type="radio" value="2" />

<input type="text" name="04" id="04"/>

</form>

当单选钮03被选中时,文本框04可编辑,其余时候文本框04 readonly

用函数写,谢谢
忘了还有个条件,当文本框readonly时,要清空这个框的值

<form onclick="check(this)">

<input name="ra" id="01" type="radio" value="0" checked="checked"/>
<input name="ra" id="02" type="radio" value="1" />
<input name="ra" id="03" type="radio" value="2" />

<input type="text" name="04" id="04" readonly="readonly"/>

</form>

JS代码:
function check (form) {
if (form.ra[2].checked) {
form['04'].readOnly= false;
} else {
form['04'].readOnly= true;
form['04'].value= "";
}
}