请大家帮我看一下我的这个判断语句,帮我找下哪有错误而且请留下解决的办法,万分感谢!
if(form1.File.value.length!=0)
{
var filetype,FileExt,filetypes;
filetype = "rar|doc|jpg|txt|gif|bmp|rtf|ppt|xls|htm";
filetypes = Split(filetype, "|");
FileExt = Extension;
for(int i=0;i<=filetypes.length-1;i++)

if(filetypes(i) = FileExt)
{  
  alert('文件上传成功!'); 
  }
else
{
alert('禁止上传文件格式:"&FileExt&",请重新选择!');
form1.File.focus();
return false;
}
}
}
还有一个问题Extension是另外一个页面的值,怎么获取到它..

解决方案 »

  1.   

    整个ASP页面的代码如下:
    <!--#include file="../include/DBConn.asp" -->
    <%Maker=session("username")
    makedate=year(now)&"-"&month(now)&"-"&day(now)ctype=request("type")
    keyword=request("keyword")
    KeyType1=request("KeyType1")
    KeyType2=request("KeyType2")
    PageNum=request("PageNum")
    mode=request("mode")thisYear=year(now)+2
    if month(now)<8 then
    Term=2
    AcademicYear=year(now)-1
    else
    Term=1
    AcademicYear=year(now)
    end if
    AcademicYear=AcademicYear&"/"&AcademicYear+1if not KeyType1="" then AcademicYear=KeyType1
    if not KeyType2="" then Term=KeyType2mode=request("mode")
    if mode = "edit" then
    id=request("id")
    if id="" or isnull(id) then id=0
    if(ISNUMERIC(id)=false) then id=0
    strSQL = "select * from workplan where state=0 and id=" & id
    set rs = objdbconn.Execute(strsql)
    if not(rs.bof or rs.eof) then
    title=rs("title")
    Content=rs("Content")
    PlanBeginWeek=rs("PlanBeginWeek")
    PlanEndWeek=rs("PlanEndWeek")
    AcademicYear=rs("AcademicYear")
    Term=rs("Term")
    Maker=rs("Maker")
    MakeDate=rs("MakeDate")
    end if
    end if
    %>
    <script language=javascript>
    <!--
    function CheckValueSave() 

    if(form1.title.value.length==0)
    {
    alert("请输入标题!");
    form1.title.focus();
    return false;
    }
    if(form1.File.value.length==0)
    {
    alert("请选择要上传的文件!");
    form1.File.focus();
    return false;
    }
    if(form1.File.value.length!=0)
    {
    var filetype,FileExt,filetypes;
    filetype = "rar|doc|jpg|txt|gif|bmp|rtf|ppt|xls|htm";
    filetypes = Split(filetype, "|");
    FileExt = Extension;
    for(int i=0;i<=filetypes.length-1;i++)

    if(filetypes(i) = FileExt)
    {  
      alert('文件上传成功!'); 
      }
    else
    {
    alert('禁止上传文件格式:"&FileExt&",请重新选择!');
    form1.File.focus();
    return false;
    }
    }
    }
    }
    function CheckValueSubmit() 

    if(form1.title.value.length==0)
    {
    alert("请输入标题!");
    form1.title.focus();
    return false;
    }
    if(form1.File.value.length==0)
    {
    alert("请选择要上传的文件!");
    form1.File.focus();
    return false;
    }
    if(confirm("注意:你制定的计划一旦提交,\n将被系统存档,且不可修改、不可删除!\n你要确认提交么?")==true)
    {
    form1.mode.value="submit";
    form1.submit();
    }
    }
    //-->
    </script>
      

  2.   

    接上帖:
    <html>
    <head>
    <title><%=ctype%></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    .unnamed1 {  font-size: 12px}
    -->
    </style>
    </head><body bgcolor="#FFFFFF" text="#000000">
    <table border="1" cellspacing="0" cellpadding="2" bordercolorlight="#5C95D5"bordercolor="#ffffff" width="90%" id="AutoNumber1" align="center" class="unnamed1">
      <form name="form1" method="post"  action="save.asp" enctype="multipart/form-data">
        <input type=hidden name="mode" value="<%=mode%>">
        <input type=hidden name="id" value="<%=id%>">
        <input type=hidden name="PageNum" value="<%=PageNum%>">
        <input type=hidden name="type" value="<%=ctype%>">
        <input type=hidden name="KeyType1" value="<%=KeyType1%>">
        <input type=hidden name="KeyType2" value="<%=KeyType2%>">
        <input type=hidden name="keyword" value="<%=keyword%>">
        <tr align="center" bgcolor="#82AEDF"> 
          <td height="19" valign="top" colspan="3"><b><font color="#FFFFFF"> 
            <%if mode = "edit" then%>修改<%else%>添加<%end if%><%=ctype%> </font></b></td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right">标题:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <p> 
              <input type="text" name="title" value="<%=title%>">
              <font color="#FF0000">(*)</font></p>
          </td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right">内容:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <textarea name="Content" cols="50" rows="6"><%=content%></textarea>
          </td>
        </tr>
        <TR>
           <TD height="28" width="341" align="right">附件:</TD>
           <TD height="28" valign="top" colSpan="2" width="548">
            <INPUT id="File" type="file" name="File">
           </TD>
        </TR>
        <tr> 
          <td height="28" width="341" align="right">计划开始周:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <select name="PlanBeginWeek" onchange="UpdateEndWeek()">
              <%for i=1 to 30%>
              <option value="<%=i%>"><%=i%></option>
            <%next%>
    <script language=javascript>
    <!--
    PlanBeginWeek="<%=PlanBeginWeek%>";
    le=form1.PlanBeginWeek.options.length;
    for(i=0;i<le;i++)
    {
    if(form1.PlanBeginWeek.options[i].value==PlanBeginWeek)form1.PlanBeginWeek.selectedIndex=i;
    }

    function UpdateEndWeek()
    {
    le=form1.PlanEndWeek.options.length;
    iPlanEndWeek=form1.PlanBeginWeek.value;
    for(i=0;i<le;i++)
    {
    form1.PlanEndWeek.remove(0);
    }
    for(i=30;i>=iPlanEndWeek;i--)
    {
    var oOption = document.createElement("OPTION");
    form1.PlanEndWeek.add(oOption,0);
    oOption.innerText=i;
    oOption.value=i;
    }
    form1.PlanEndWeek.selectedIndex=0;
    }
    //-->
    </script>
            </select>
          </td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right">计划结束周:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <select name="PlanEndWeek">
              <%for i=1 to 30%>
              <option value="<%=i%>"><%=i%></option>
            <%next%>
    <script language=javascript>
    <!--
    PlanEndWeek="<%=PlanEndWeek%>";
    le=form1.PlanEndWeek.options.length;
    for(i=0;i<le;i++)
    {
    if(form1.PlanEndWeek.options[i].value==PlanEndWeek)form1.PlanEndWeek.selectedIndex=i;
    }
    //-->
    </script>
            </select>
          </td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right"> 
            <p>学年:</p>
          </td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <select name="AcademicYear">
              <%for i=1999 to thisyear%>
              <option value="<%=i%>/<%=i+1%>"><%=i%>/<%=i+1%></option>
              <%next%>
    <script language=javascript>
    <!--
    AcademicYear="<%=AcademicYear%>";
    le=form1.AcademicYear.options.length;
    for(i=0;i<le;i++)
    {
    if(form1.AcademicYear.options[i].value==AcademicYear)form1.AcademicYear.selectedIndex=i;
    }
    //-->
    </script>
            </select>
          </td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right">学期:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <select name="Term">
              <option value="1">第一学期</option>
              <option value="2">第二学期</option>
              <script language=javascript>
    <!--
    Term="<%=Term%>";
    le=form1.Term.options.length;
    for(i=0;i<le;i++)
    {
    if(form1.Term.options[i].value==Term)form1.Term.selectedIndex=i;
    }
    //-->
    </script>
            </select>
          </td>
        </tr>
        <tr> 
          <td height="28" width="341" align="right">制定人:</td>
          <td height="28" valign="top" colspan="2" width="548"> 
            <input type="text" name="Maker" value="<%=Maker%>">
          </td>
        </tr>
        <tr> 
          <td height="29" width="341" align="right">制定日期:</td>
          <td height="29" valign="top" colspan="2" width="548"> 
            <input type="text" name="MakeDate" value="<%=makedate%>">
          </td>
        </tr>
        <tr align="center"> 
          <td height="28" colspan="3"> 
            <table width="80%" cellspacing="0" cellpadding="0">
          <tr> 
                <td align="center"> 
                  <input type="submit" value=" 保存 " name="btnOK" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #5C95D5 1px solid; BORDER-LEFT: #5C95D5 1px solid; BORDER-RIGHT: #5C95D5 1px solid; BORDER-TOP: #5C95D5 1px solid" onClick="JavaScript:return CheckValueSave();">              <input type="button" value=" 重写 " name="btnReset" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #5C95D5 1px solid; BORDER-LEFT: #5C95D5 1px solid; BORDER-RIGHT: #5C95D5 1px solid; BORDER-TOP: #5C95D5 1px solid" onClick="JavaScript:form1.reset();">
                  <input type="button" value=" 返回 " name="btnReset2" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #5C95D5 1px solid; BORDER-LEFT: #5C95D5 1px solid; BORDER-RIGHT: #5C95D5 1px solid; BORDER-TOP: #5C95D5 1px solid" onClick="JavaScript:history.back();">
                                 <input type="button" value=" 提交 " name="btnOK2" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #5C95D5 1px solid; BORDER-LEFT: #5C95D5 1px solid; BORDER-RIGHT: #5C95D5 1px solid; BORDER-TOP: #5C95D5 1px solid" onClick="JavaScript:return CheckValueSubmit();">
                </td>
          </tr>
        </table></td>
        </tr>
        
      </form>
    </table>
    </body>
    </html>