jsp页面里的单选框(radio) 有三个单选框 a b 其它, 其它后面要有文本框,1, 当点其它单选框时文本框可输入值, 当点a或b文本框不可用,2,当点b时要控制一个下拉链表可用, 当点 a 和 其它 时下拉链表不可用.3,谢谢大家. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对单选按钮添加onclick事件,在事件里根据情况设置文本框跟下拉列表的 disabled属性,例如点其它的时候document.getElementById("textId").disabled =false;document.getElementById("selectId").disabled =true; 贴代码:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script> function _change(obj){ if(obj.value == 'other') document.getElementById("othertxt").disabled=false; else document.getElementById("othertxt").disabled=true; if(obj.value == 'b') document.getElementById("ms").disabled=false; else document.getElementById("ms").disabled=true; } </script> </HEAD> <BODY> <input type="radio" name="ra" id="ra" onclick="_change(this);" value="a"/> a <input type="radio" name="ra" id="ra" onclick="_change(this);" value="b"/> b <input type="radio" name="ra" id="ra" onclick="_change(this);" value="other"/> 其他 <input type="text" name="othertxt" id="othertxt" disabled/> <select id="ms" name="ms" disabled> <option name="a">下拉列表a</option> <option name="b">下拉列表b</option> <option name="c">下拉列表c</option> </select> </BODY></HTML> jquery版<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script src="jquery.js"></script> <script> $(function(){ $("input[name='ra']").click(function(){ _change($(this)); }); }); function _change(obj){ if(obj.val() == 'other'){ $("#othertxt").attr("disabled",false); } else { $("#othertxt").val("").attr("disabled",true); } if(obj.val() == 'b'){ $("#ms").attr("disabled",false); } else{ $("#ms").attr("disabled",true); } } </script> </HEAD> <BODY> <input type="radio" name="ra" id="ra1" value="a"/> a <input type="radio" name="ra" id="ra2" value="b"/> b <input type="radio" name="ra" id="ra3" value="other"/> 其他 <input type="text" name="othertxt" id="othertxt" disabled/> <select id="ms" name="ms" disabled> <option name="a">下拉列表a</option> <option name="b">下拉列表b</option> <option name="c">下拉列表c</option> </select> </BODY></HTML> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script> function _change(obj){ if(obj.value == 'other') document.getElementById("othertxt").disabled=false; else document.getElementById("othertxt").disabled=true; if(obj.value == 'b') document.getElementById("ms").disabled=false; else document.getElementById("ms").disabled=true; } </script> </HEAD> <BODY> <input type="radio" name="ra" id="ra" onclick="_change(this);" value="a"/> a <input type="radio" name="ra" id="ra" onclick="_change(this);" value="b"/> b <input type="radio" name="ra" id="ra" onclick="_change(this);" value="other"/> 其他 <input type="text" name="othertxt" id="othertxt" disabled/> <select id="ms" name="ms" disabled> <option name="a">下拉列表a</option> <option name="b">下拉列表b</option> <option name="c">下拉列表c</option> </select> </BODY></HTML> jquery根据当前行的超链接,做字段隐藏和文本显示 请高手帮我写一条SQL语句,符合实现的有奖励100分 新手求帮助:dreamwaver中用vbs的简单问题,请帮忙 突然想到一个连接池的问题 高分求助:如何在多台服务器之间实现session的复制 java与jsp有何区别? 哪里能够得到媒体播放器如mpeg,mp3等的组件? weblogic6.0的问题? jdbcTemplate为空求指教 spring手动注入 数据库很快连接数就超了,怎么回事? 【急】excel导出的数据的数字型显示科学计数法 struts错误,高手帮帮忙啊
document.getElementById("textId").disabled =false;
document.getElementById("selectId").disabled =true;
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function _change(obj){
if(obj.value == 'other')
document.getElementById("othertxt").disabled=false;
else
document.getElementById("othertxt").disabled=true;
if(obj.value == 'b')
document.getElementById("ms").disabled=false;
else
document.getElementById("ms").disabled=true;
}
</script>
</HEAD> <BODY>
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="a"/> a
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="b"/> b
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="other"/> 其他 <input type="text" name="othertxt" id="othertxt" disabled/>
<select id="ms" name="ms" disabled>
<option name="a">下拉列表a</option>
<option name="b">下拉列表b</option>
<option name="c">下拉列表c</option>
</select>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script src="jquery.js"></script>
<script>
$(function(){
$("input[name='ra']").click(function(){
_change($(this));
});
});
function _change(obj){
if(obj.val() == 'other'){
$("#othertxt").attr("disabled",false);
}
else {
$("#othertxt").val("").attr("disabled",true);
}
if(obj.val() == 'b'){
$("#ms").attr("disabled",false);
}
else{
$("#ms").attr("disabled",true);
}
}
</script>
</HEAD> <BODY>
<input type="radio" name="ra" id="ra1" value="a"/> a
<input type="radio" name="ra" id="ra2" value="b"/> b
<input type="radio" name="ra" id="ra3" value="other"/>
其他 <input type="text" name="othertxt" id="othertxt" disabled/>
<select id="ms" name="ms" disabled>
<option name="a">下拉列表a</option>
<option name="b">下拉列表b</option>
<option name="c">下拉列表c</option>
</select>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function _change(obj){
if(obj.value == 'other')
document.getElementById("othertxt").disabled=false;
else
document.getElementById("othertxt").disabled=true;
if(obj.value == 'b')
document.getElementById("ms").disabled=false;
else
document.getElementById("ms").disabled=true;
}
</script>
</HEAD> <BODY>
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="a"/> a
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="b"/> b
<input type="radio" name="ra" id="ra" onclick="_change(this);" value="other"/> 其他 <input type="text" name="othertxt" id="othertxt" disabled/>
<select id="ms" name="ms" disabled>
<option name="a">下拉列表a</option>
<option name="b">下拉列表b</option>
<option name="c">下拉列表c</option>
</select>
</BODY>
</HTML>