隐藏span! 一个下拉列表,value值有:“按时间段查询”,"按用户名查询".我想要的是:当选“按时间段查询”时,出来两个有日期标签的输入框,当选"按用户名查询"出来一个输入框就行。怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <span style="display:none"> <html><head><title></title></head><body> <form id="formid" action="index.html"> <select onchange="test1(this)" id="_select"> <option value="0">--请选择--</option> <option value="1">aa</option> <option value="2">bb</option> </select> <div id="div_bb" style="display:none"> <input name="bb" id="bb" value="testbb"></div> <div id="div_aa" style="display:none"><input name="aa" id="aa" value="testaa"></div></form></body></html><script>function test1(_obj){ var _value = _obj.value; if(_value == 1) { document.getElementById("div_bb").style.display = "none"; document.getElementById("div_aa").style.display = "block"; }else if(_value == 2) { document.getElementById("div_bb").style.display = "block"; document.getElementById("div_aa").style.display = "none"; }else { document.getElementById("div_bb").style.display = "none"; document.getElementById("div_aa").style.display = "none"; } }</script>临时写的,不太简练,lz拿去参考一下吧 <!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=""><style>div{ position:absolute; display:none; top:12px;}</style><script>function control(){ var sel = document.getElementById("sel"); var selvalue = sel.options[sel.selectedIndex].value; if(selvalue == "1"){ document.getElementById("span_1").style.display = "block"; document.getElementById("span_2").style.display = "none"; } if(selvalue == "2"){ document.getElementById("span_1").style.display = "none"; document.getElementById("span_2").style.display = "block"; } if(selvalue == "0"){ document.getElementById("span_1").style.display = "none"; document.getElementById("span_2").style.display = "none"; } }</script></head><body><select id="sel" onchange="control();"><option value="0">请选择查询方式</option><option value="1">按时间查询</option><option value="2">按用户查询</option></select><div id="span_1" >===请选择时间===</div><div id="span_2"><input type="text" value="请输入用户名"></div></body></html> 哈哈!谢谢各位!结贴了。对了,如果是div的显示的用block如果用的是span要用inline噢! 这段代码里的/^gsx/.test什么意思啊? 为什么最后的js要等图片加载后才能调用? extjs RTX Client SDK中的Kernalroot对象创见时能不能不打开RTX客户端? 我想要实现的结果是默认状态下,都关闭,然后当当点击一个的时候另外一个关闭。 google chrome 下的SVG问题 求JS 一个很奇怪的问题,我在js中动态改变图象对象的scr后 一个很菜的问题,请大家指点! 网页加密技术(即,进网页要先登陆,就象进这个论坛那样) 初学,ext tree没显示出来。 用canvas模拟小球碰撞,请大家不吝赐教
<head>
<title></title>
</head>
<body>
<form id="formid" action="index.html">
<select onchange="test1(this)" id="_select">
<option value="0">--请选择--</option>
<option value="1">aa</option>
<option value="2">bb</option>
</select>
<div id="div_bb" style="display:none"> <input name="bb" id="bb" value="testbb"></div>
<div id="div_aa" style="display:none"><input name="aa" id="aa" value="testaa"></div>
</form>
</body>
</html>
<script>
function test1(_obj)
{
var _value = _obj.value;
if(_value == 1)
{ document.getElementById("div_bb").style.display = "none";
document.getElementById("div_aa").style.display = "block";
}else if(_value == 2)
{ document.getElementById("div_bb").style.display = "block";
document.getElementById("div_aa").style.display = "none";
}else
{
document.getElementById("div_bb").style.display = "none";
document.getElementById("div_aa").style.display = "none";
}
}</script>
临时写的,不太简练,lz拿去参考一下吧
<!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="">
<style>
div{
position:absolute;
display:none;
top:12px;
}
</style>
<script>
function control(){
var sel = document.getElementById("sel");
var selvalue = sel.options[sel.selectedIndex].value;
if(selvalue == "1"){
document.getElementById("span_1").style.display = "block";
document.getElementById("span_2").style.display = "none";
}
if(selvalue == "2"){
document.getElementById("span_1").style.display = "none";
document.getElementById("span_2").style.display = "block";
}
if(selvalue == "0"){
document.getElementById("span_1").style.display = "none";
document.getElementById("span_2").style.display = "none";
}
}
</script>
</head><body>
<select id="sel" onchange="control();">
<option value="0">请选择查询方式</option>
<option value="1">按时间查询</option>
<option value="2">按用户查询</option>
</select>
<div id="span_1" >
===请选择时间===
</div>
<div id="span_2">
<input type="text" value="请输入用户名">
</div>
</body>
</html>