我在一个页面里写了一段javascript代码,用来控制这个页面的必添选项,而且已经成功了
但是,当我把这个页面移动了一下位置,也就是把这个页面放在了另一个文件夹下面时,这个页面里的javascript代码就不起作用了,我一直弄不明白是怎么回事?
如果有知道的,请给我一个答案,谢谢!!!

解决方案 »

  1.   

    你是不是把javascript写到一个*.js文件里面啊,然后在页面中引用这个js文件,然后你移了文件,就找不到js文件了.
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
    <html>
    <head>
    <title>
    无标题文档
    </title>
    <%
       String[] FirstDeptName = (String[])request.getAttribute("FirstDeptName");
       String[] secondept = (String[])request.getAttribute("secondept");
       %>
     <script language="javascript">
      function checkForm(){
       if(document.will.title.value.length <= 0){
         alert("请输入标题名称!!");
         return false;
       }
       if(document.will.age.value.length <= 0){
         alert("请输入年龄!!");
         return false;
       }
       if(document.will.IllHistory.value.length <= 0){
         alert("请输入病史!!");
         return false;
       }
       if(document.will.AskAim.value.length <= 0){
         alert("请输入目的!!");
         return false;
       }
       if(document.will.SecondDeptTyep.value.length <= 0 ){
         alert("请选择所属科室!!");
         return false;
       }
       return true;
     }
     
     var classlist = [];
    <% for(int i=0;i<FirstDeptName.length;i++) {
    String[] sec = secondept[i].split(",");
    List seclist = new ArrayList();
    seclist.add(sec[0].substring(1,sec[0].length()));
    if(sec.length>1){

    for(int j=1;j<sec.length-1;j++){
    seclist.add(sec[j]);

    }
    seclist.add(sec[sec.length-1].substring(0,sec[sec.length-1].length()-1));
    }
    %>
    classlist[<%= i+1 %>] = new Array( new Option(  '<%= seclist.get(0)%>','<%= i+1 %>')<% for(int j=1;j<seclist.size();j++){ %> , new Option( '<%= seclist.get(j)%>','<%= i+1%>')<% }%>);
    <%}%>
                      
    function s(sid){
    if (sid==""){
    document.will.s2.length=0;
    document.will.s2.add(new Option("-不选-",""));
    }
    else{
    document.will.s2.length=0;
    if (classlist[sid].length>0){

      document.will.s2.add(new Option("-选择-","")); for (var i=0;i<classlist[sid].length;i++){
    document.will.s2.add(classlist[sid][i]);
    }
    }
    }
    }
     </script>
    <link href="file:///C|/Tomcat 5.5/webapps/ROOT/leave_ word/style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
      body {
     margin-left: 0px;
     margin-top: 0px;
     margin-right: 0px;
     margin-bottom: 0px;
     background-color: #EFEBEF;
     }
    .STYLE3 {color: #9C0000}
    -->
    </style></head>

    <body>   
     <form method="post" action="Asksuccess.do" name="will" enctype="multipart/form-data" onsubmit="return checkForm();">
          <table width="505" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td width="198" rowspan="3"><img id="tw_03" src="../leave_ word/img/tw_03.gif" width="198" height="68" alt="" /></td>
              <td height="26" colspan="2">&nbsp;</td>
            </tr>
            <tr> 
              <td width="320" height="27" bgcolor="#E5F7D3">&nbsp;</td>
              <td width="14" height="27" valign="bottom"><img id="tw_07" src="../leave_ word/img/tw_07.gif" width="14" height="27" alt="" /></td>
            </tr>
            <tr> 
              <td colspan="2" align="right" valign="bottom" bgcolor="#4EC211"><span class="STYLE3"><font color="#FFFFFF">本站专家将在二十四小时内及时给予回复!</font></span></td>
            </tr>
            <tr bgcolor="#E5F7D3"> 
              <td height="479" colspan="3" valign="top"><br /> <br /> 
                <table width="483" border="0" align="center" cellpadding="0" cellspacing="1">
                  <tr align="center"> 
                    <td height="25" colspan="6">带<font color="#FF0000">*</font>号均属必填内容,请尽量详细填写你的提问信息!</td>
                  </tr>
                  <tr> 
                    <td width="78" height="25"><strong>问题标题:</strong></td>
                    <td height="25" colspan="5"><input name="title" size="30"/> 
                      <font color="#FF0000">*</font></td>
                  </tr>
                  <tr> 
                    <td height="26"><strong>患者性别:</strong><br /></td>
                    <td width="91" height="26">
    <select name="sex">
                        <option selected="selected">男</option>
                        <option>女</option>
                      </select> <font color="#FF0000">*</font></td>
                    <td width="41" height="26"><strong>年龄:<br />
                      </strong></td>
                    <td width="108" height="26">
    <input name="age" type="text" size="3" maxlength="3" />
                      岁<font color="#FF0000">*</font></td>
                    <td width="44">&nbsp;</td>
                    <td width="114">&nbsp; </td>
                  </tr>
                  <tr> 
                    <td height="100"><strong>以往诊断治疗经过(病史):</strong><br /></td>
                    <td height="120" colspan="5"> <textarea name="IllHistory" cols="52" rows="7"></textarea> 
                      <font color="#FF0000">*</font> </td>
                  </tr>
                  <tr> 
                    <td height="100"><strong>目前病情及咨询目的:</strong></td>
                    <td height="120" colspan="5"> <textarea name="AskAim" cols="52" rows="7"></textarea> 
                      <font color="#FF0000">*</font> </td>
                  </tr>
                  <tr> 
                    <td height="68"><strong>所属类别:</strong></td>
                    <td height="68" colspan="5"> <table width="362" border="0" cellspacing="0" cellpadding="0">
                        <tr> 
                          <td width="158" height="22">所属大类:</td>
                          <td width="204">所属小类:</td>
                        </tr>
                        <tr> 
                          <td height="27"> <select id=select  style="WIDTH: 100px"  onchange=s(this.value); name=s1>
                             <%
                             
                              for(int i=0;i<FirstDeptName.length;i++){                           
                             %>
                              <option selected value=<%= i+1 %>><%= FirstDeptName[i] %></option>
                                 <% } %>              
                            </select>
                          </td>
                          <td><select id=select2  name=s2>
                             
                              
                            </select> <font color="#FF0000">*</font></td>
                        </tr>
                      </table></td>
                  </tr>
              
                  <tr> 
                    <td height="25"><strong>相关图片:</strong></td>
                    <td height="25" colspan="5">
                  
                       <input name=file type=file style="width:360"  value="" />
                      
                      图片大小限制(500K)

    </td>
                    
                  </tr>
                  
                  <tr> 
                    <td height="38" colspan="6" align="center" valign="bottom">
    <INPUT type="hidden" name="AskEim" value="1" /> <input type="image" src="../leave_  word/img/tj.gif" width="57" height="20"/>
    </td>
                  </tr>
                </table>     
                </td>
            </tr>
            <tr> 
              <td colspan="3"><img id="tw_10" src="../leave_ word/img/tw_10.gif" width="532" height="18" alt="" /></td>
            </tr>
          </table>
       </form>
          <br />
        </td>
      </tr>
    </table><table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img id="sy_53" src="../leave_ word/img/sy_53.gif" width="778" height="84" alt="" /></td>
      </tr>
    </table>
    </body>
    </html>
      

  3.   

    应该不会有这样的事发生的啊。可能是你代码里有什么错误(指的不是javascript)
      

  4.   

    我个人的意见是这个页面就没有识别javascript文件,,但是错在哪里,我就是没有找到
    真着急啊,是不是前面页面的脚本文件和它冲突呢?
    javascript作用域是什么啊?
    是指在本页面吗?