如何用javascript实现,点击不同表格里的内容,在一个指定的表格里显示不同的帮助提示
如图,点击A表格的内容(包括文字、单选、复选等内容),在C表格里显示A相关的内容,点击B时,在C里就显示B相关的内容。...
如图,点击A表格的内容(包括文字、单选、复选等内容),在C表格里显示A相关的内容,点击B时,在C里就显示B相关的内容。
展开
1个回答
展开全部
很简单的问题,找到他们的触发事件即可。
<!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>
<title>js</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
#div1 {
width:300px;
height:200px;
border:1px solid #ccc;
margin:0px auto;
padding-left:80px;
padding-top:30px;
font-size:15px;
font-family:"宋体";
line-height:175%;
}
</style>
</head>
<body>
<div id="div1">
<p><input id="radio1" type="radio" value="a" onclick="javascript:showinfo(this.value);"> a
<input id="radio2" type="radio" value="b" onclick="javascript:showinfo(this.value);"> b </p>
<p><select id="select1" onchange="javascript:showinfo(this.value);" name="select1">
<option value="aa">aa</option>
<option value="bb">bb</option>
</select>
</p>
<p><span id="helpinfo">帮助信息</span></p>
</div>
<script type="text/javascript">
var help = document.getElementById("helpinfo");
function showinfo(value)
{
switch(value)
{
case "a":
help.innerHTML = "a";
document.getElementById("radio2").checked=false;
break;
case "b":
help.innerHTML = "b";
document.getElementById("radio1").checked=false;
break;
case "aa":
help.innerHTML = "aa";
break;
case "bb":
help.innerHTML = "bb";
break;
default:
break;
}
}
</script>
</body>
</html>
<!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>
<title>js</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
#div1 {
width:300px;
height:200px;
border:1px solid #ccc;
margin:0px auto;
padding-left:80px;
padding-top:30px;
font-size:15px;
font-family:"宋体";
line-height:175%;
}
</style>
</head>
<body>
<div id="div1">
<p><input id="radio1" type="radio" value="a" onclick="javascript:showinfo(this.value);"> a
<input id="radio2" type="radio" value="b" onclick="javascript:showinfo(this.value);"> b </p>
<p><select id="select1" onchange="javascript:showinfo(this.value);" name="select1">
<option value="aa">aa</option>
<option value="bb">bb</option>
</select>
</p>
<p><span id="helpinfo">帮助信息</span></p>
</div>
<script type="text/javascript">
var help = document.getElementById("helpinfo");
function showinfo(value)
{
switch(value)
{
case "a":
help.innerHTML = "a";
document.getElementById("radio2").checked=false;
break;
case "b":
help.innerHTML = "b";
document.getElementById("radio1").checked=false;
break;
case "aa":
help.innerHTML = "aa";
break;
case "bb":
help.innerHTML = "bb";
break;
default:
break;
}
}
</script>
</body>
</html>
追问
兄弟,这段代码的单选有些问题哦~~点击后,不能显示已选
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询