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

关于表单和js的问题
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<script   language= "javascript ">
function   show4(obj,str){
var   td   =   document.getElementById(str);
if(checkBoxId.checked   ==   true){
td.style.display   =   "block ";
}else{
td.style.display   =   "none ";
}
}
</script>
<body>
<form>
<table   width= "75% "   border= "1 ">
    <tr>
        <td   width= "23% "> 1.什么是医疗保险
<input   type= "checkbox "   name= "checkbox "   id= "checkBoxId "     onclick= "show4(this, 'show1 ') "/> </td>
        <td   width= "77% "   id= "show1 "   style= "display:none "> <select   name= "select ">
                    <option> 11111111 </option>
                    <option> 2222222222 </option>
                    <option> 33333333 </option>
        </select> </td>
    </tr>
</table>
</form>


这个为什么我给form去掉,就可以用啊,不去掉就不能用

------解决方案--------------------
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<script language= "javascript ">
function show4(obj,str){
var td = document.getElementById(str);
if(document.getElementById( "checkbox ").checked == true){
document.getElementById( "show1 ").style.display = "block ";
}else{
document.getElementById( "show1 ").style.display = "none ";
}
}
</script>
<body>
<form>
<table width= "75% " border= "1 ">
<tr>
<td width= "23% "> 1.什么是医疗保险
<input type= "checkbox " name= "checkbox " id= "checkbox " onClick= "show4(this, 'show1 ') "/> </td>
<td width= "77% "> <div id= "show1 " style= "display:none "> <select name= "select ">
<option> 11111111 </option>
<option> 2222222222 </option>
<option> 33333333 </option>
</select> </div> </td>
</tr>
</table>
</form>