日期:2014-05-16  浏览次数:20331 次

触发事件的问题
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<script   language= "javascript ">
function   show(obj,str){
var   td   =   document.getElementById(str);
if(obj.innerText   ==   "显示 "){
obj.innerText   =   "隐藏 ";
td.style.display   =   "block ";
}else{
obj.innerText   =   "显示 ";
td.style.display   =   "none ";
}
}
</script>
</head>

<body>
<table   width= "75% "   border= "1 ">
    <tr>
        <td   colspan= "2 "   align= "center "> 信息常识 <a   name= "top ">   </a> </td>
    </tr>
    <tr>
        <td   width= "29% "> 1.什么是医疗保险?   <a   href= "# "   id= "id1 "   onclick= "show(this, 'show1 ') "> 显示 </a> </td>
        <td   width= "71% "   id= "show1 "   style= "display:none "> <select   name= "select ">
                    <option> 11111111 </option>
                    <option> 2222222222 </option>
                    <option> 33333333 </option>
        </select> </td>
    </tr>
    <tr>
        <td   colspan= "2 "> &nbsp;         </td>
    </tr>
</table>
</body>
</html>

这个页面   我想把“显示”和“隐藏”变成用复选框打钩的形式来触发事件要怎么改啊

------解决方案--------------------
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<script language= "javascript ">
function show(val){

if(val==1 && document.getElementById( "ckShow ").checked)
{
document.getElementById( "ckHidden ").checked=false;
document.getElementById( "show1 ").style.display = "block ";
}
else if(val==0 && document.getElementById( "ckHidden ").checked)
{document.getElementById( "ckShow ").checked=false;
document.getElementById( "show1 ").style.display = "none ";
}
}
</script>
</head>

<body>
<table width= "75% " border= "1 ">
<tr>
<td colspan= "2 " align= "center "> 信息常识 <a name= "top "> </a> </td>
</tr>
<tr>
<td width= "29% "> 1.什么是医疗保险?
<INPUT type= "checkbox " id= "ckShow " checked onclick=