<!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>
 用户登录
</title>
</head>
<body style="text-align:center">
    <form name="theform" method="post" action="UserLogin.aspx" id="theform">
     <table cellpadding="0" cellspacing="0" style="width:100%; text-align:center">
        <tr>
         <td style="width:8%">工作权限</td>
         <td style="width:15%; text-align:left">
             <select name="dpScope" id="dpScope" 
              onchange="Jump(document.theform.dpScope.options[document.theform.dpScope.selectedIndex].value)" style="width:80%;">
<option selected="selected" value="2">班组级</option>
<option value="1">部门级</option>
<option value="0">局级</option>
</select>
        </td>
        <td id="TrDepart" name="TrDepart" style="display:block ">
              所属部门     
        </td>
        <td id="TrGroup" name="trGroup" style="display:block ">
            所属班组
        </td>
      </tr> 
    </table>
</form>
    <script type="text/javascript">
    function Jump(nScope)
    {
         switch(nScope) {
         case 0:
            document.GetElementById('TrDepart').style.display = "none";
            document.GetElementById('TrGroup').style.display = "none";
          break;
         case 1:
            document.GetElementById('TrDepart').style.display = "block";
            document.GetElementById('TrGroup').style.display = "none";
          break;
         case 2:
            document.GetElementById('TrDepart').style.display = "block";
            document.GetElementById('TrGroup').style.display = "block";
          break;
         default:
            document.GetElementById('TrDepart').style.display = "block";
            document.GetElementById('TrGroup').style.display = "block";
          break;
         }
    }
</script>
</body>
</html>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             功能很简单,就是根据select里option的值,控制后面两列显示或隐藏。可一直提示document.GetElementById('TrDepart').style.display 不支持该属性

解决方案 »

  1.   

    getElementById小写开头 document.getElementById
      

  2.   

    switch(parseInt(nScope)) <!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>
         用户登录
    </title>
    </head>
    <body style="text-align:center">
        <form name="theform" method="post" action="UserLogin.aspx" id="theform">
         <table cellpadding="0" cellspacing="0" style="width:100%; text-align:center">
            <tr>
             <td style="width:8%">工作权限</td>
             <td style="width:15%; text-align:left">
                 <select name="dpScope" id="dpScope" 
                     onchange="Jump(document.theform.dpScope.options[document.theform.dpScope.selectedIndex].value)" style="width:80%;">
                                <option selected="selected" value="2">班组级</option>
                                <option value="1">部门级</option>
                                <option value="0">局级</option>
                                </select>
            </td>
            <td id="TrDepart" name="TrDepart" style="display:block ">
                  所属部门     
            </td>
            <td id="TrGroup" name="trGroup" style="display:block ">
                所属班组
            </td>
          </tr> 
        </table>
    </form>
        <script type="text/javascript">
        function Jump(nScope)
        {
             switch(parseInt(nScope)) {
             case 0:
                document.getElementById('TrDepart').style.display = "none";
                document.getElementById('TrGroup').style.display = "none";
                 break;
             case 1:
                document.getElementById('TrDepart').style.display = "block";
                document.getElementById('TrGroup').style.display = "none";
                 break;
             case 2:
                document.getElementById('TrDepart').style.display = "block";
                document.getElementById('TrGroup').style.display = "block";
                 break;
             default:
                document.getElementById('TrDepart').style.display = "block";
                document.getElementById('TrGroup').style.display = "block";
                 break;
             }
        }
    </script>
    </body>
    </html>
      

  3.   

    <!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>用户登录</title>
    </head>
    <body style="text-align:center">
    <form name="theform" method="post" action="UserLogin.aspx" id="theform">
    <table cellpadding="0" cellspacing="0" style="width:100%; text-align:center">
    <tr>
    <td style="width:8%">工作权限</td>
    <td style="width:15%; text-align:left">
    <select name="dpScope" id="dpScope" onchange="Jump(this.value)" style="width:80%;">
    <option selected="selected" value="2">班组级</option>
    <option value="1">部门级</option>
    <option value="0">局级</option>
    </select>
    </td>
    <td id="TrDepart" name="TrDepart" style="display:block ">所属部门 </td>
    <td id="TrGroup" name="trGroup" style="display:block ">所属班组</td>
    </tr>
    </table>
    </form>
    <script type="text/javascript">
    function Jump(nScope){
    nScope = parseInt(nScope);
    var TrDepart = document.getElementById('TrDepart'),
    TrGroup = document.getElementById('TrGroup');
    switch (nScope) {
    case 0:
    TrDepart.style.display = "none";
    TrGroup.style.display = "none";
    break;
    case 1:
    TrDepart.style.display = "block";
    TrGroup.style.display = "none";
    break;
    case 2:
    TrDepart.style.display = "block";
    TrGroup.style.display = "block";
    break;
    default:
    TrDepart.style.display = "block";
    TrGroup.style.display = "block";
    break;
    }
    }
    </script>
    </body>
    </html>
      

  4.   

    刚弄完这样的类型.
    呵,
    确实是document.getElementById('TrGroup').style.display = "block";
    这样写莫有错,如果是放在body中的话,是不是应该是<script></script>放在它们俩里面呢.
      

  5.   

    document.getElementById小写是一个问题,主要问题是 case 0: case 1:这部分,因为传过来的是字符串不是数字,所以改为 case '0': case '1':等等,测试通过