突然想到一个问题不知如何实现 一个单选框: " 是 否 " 两个选项如果选 "是" 则可以填写是下面的文本框如果选 "否" 则只能填否下面的也就是说先完成单选,才能填文本框,但是单选框与文本框都有与其对应的,不可以交叉选填能不能做到呢?请高人指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 思路很简单,只要选"是"的就让文本框enable,否则一直不可用,按楼主的问题,"否"是多余了吧 方法和二楼一样,先让文本框都失效disabled=true;然后给单选按钮做相关的事件就可以了。再事件中,只要改变相关的文本框disabled="";就可以了。 radio1 默认选中radio2 默认没有选中div1 里面内容为是的内容 默认显示div2 里面内容为否的内容 默认不显示在 radio1和radio2上绑定click事件,点击radio1的时候,div1显示,div2隐藏,点击radio2的时候,div2显示,div1隐藏 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>ceshi</title><style></style><script src="jquery-1.3.2.js"></script><script>$(function(){ $("input[class=ok]").click(function(){ if($(this).is(":checked")){ $(this).next().next().attr("readonly",true).css("background","#ccc"); $(this).next().attr("checked",false); }else{ $(this).next().next().attr("readonly",false).css("background","#fff"); $(this).next().attr("checked",true); } }); $("input[class=no]").click(function(){ if($(this).is(":checked")){ $(this).next().attr("readonly",false).css("background","#fff"); $(this).prev().attr("checked",false); }else{ $(this).next().attr("readonly",true).css("background","#ccc"); $(this).prev().attr("checked",true); } });});</script></head><body><div id="all"> <div class="test"> <input type="radio" class="ok" />是<input type="radio" class="no" />否 <input type="text" class="text" /> </div> <div class="test"> <input type="radio" class="ok" />是<input type="radio" class="no" />否 <input type="text" class="text" /> </div> <div class="test"> <input type="radio" class="ok" />是<input type="radio" class="no" />否 <input type="text" class="text" /> </div></div></body></html> 实现 按钮的onchange事件另外 不管 是 或者 否 都可以填一个文本框则 一组状态按钮 是|否 单独一个文本框 就可以了 不必搞这么复杂 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript">function btnClick(inputName, disableInputName) { var input = document.getElementById(inputName); var disableInputName = document.getElementById(disableInputName); input.disabled = false; disableInputName.disabled = true;}</script></head><body><input type="radio" name="select" checked="true" onclick="btnClick('textYes', 'textNo')"></input><input type="text" name="textYes"></input><input type="radio" name="select" onclick="btnClick('textNo', 'textYes')"></input><input type="text" name="textNo" disabled="true"></input></body></html> 分给错了,rainsilence的是正确的。对不起啦 jquery实现导航栏始终可见。 求js eval解码方法.. #include "值",值表示的是一个变量,要怎么写呢? 为什么JS调用Flash中的函数总是不成功? 问个很简单的问题 没分了,谁帮帮我,很简单的javascript,谢谢了! 哪位大哥帮忙一下! 点击一个单选框,在单选框的显示的字后面自动出现两个复选框,如何实现? 100分问题:如何解决用一图片或一button代替file控件的外观? 那位高手能提供在网页中嵌一个文本编辑器的例子???? document.createElement("object")要怎么用,让flash显示出来? 正则表达式如何提取"[]"中的内容
再事件中,只要改变相关的文本框disabled="";就可以了。
radio2 默认没有选中
div1 里面内容为是的内容 默认显示
div2 里面内容为否的内容 默认不显示在 radio1和radio2上绑定click事件,
点击radio1的时候,div1显示,div2隐藏,
点击radio2的时候,div2显示,div1隐藏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ceshi</title>
<style>
</style>
<script src="jquery-1.3.2.js"></script>
<script>
$(function(){ $("input[class=ok]").click(function(){
if($(this).is(":checked")){
$(this).next().next().attr("readonly",true).css("background","#ccc");
$(this).next().attr("checked",false);
}else{
$(this).next().next().attr("readonly",false).css("background","#fff");
$(this).next().attr("checked",true);
}
});
$("input[class=no]").click(function(){
if($(this).is(":checked")){
$(this).next().attr("readonly",false).css("background","#fff");
$(this).prev().attr("checked",false);
}else{
$(this).next().attr("readonly",true).css("background","#ccc");
$(this).prev().attr("checked",true);
}
});
});
</script>
</head><body>
<div id="all">
<div class="test">
<input type="radio" class="ok" />是<input type="radio" class="no" />否
<input type="text" class="text" />
</div>
<div class="test">
<input type="radio" class="ok" />是<input type="radio" class="no" />否
<input type="text" class="text" />
</div>
<div class="test">
<input type="radio" class="ok" />是<input type="radio" class="no" />否
<input type="text" class="text" />
</div>
</div></body>
</html>
则 一组状态按钮 是|否 单独一个文本框 就可以了 不必搞这么复杂
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">function btnClick(inputName, disableInputName) {
var input = document.getElementById(inputName);
var disableInputName = document.getElementById(disableInputName); input.disabled = false;
disableInputName.disabled = true;
}
</script>
</head>
<body>
<input type="radio" name="select" checked="true" onclick="btnClick('textYes', 'textNo')"></input>
<input type="text" name="textYes"></input>
<input type="radio" name="select" onclick="btnClick('textNo', 'textYes')"></input>
<input type="text" name="textNo" disabled="true"></input></body>
</html>
对不起啦