如何从后台获取前台表单select的值
我已经搜了很多网上的文章,在单独使用request.form的时候能够成功,但是把功能嵌入一个上传文件的asp里面就失败了。用的艾恩无组件上传,源程序如下:
upload.htm(里面含很多css代码等,只贴出表单部分)
<form action="upload.asp" method="post" name="form1" id="form1">
<select id="Distinction" name="Distinction" size="1" onchange="Redirect(this.options.selectedIndex)">
<option selected value="0">选择栏目</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<select id="purpose" name="purpose" size="1">
<option value="1">选择分类</option>
</select>
<input type="submit" name="Submit2" value="上传" />
</form>
因为这个是二级联动菜单,所以onchange已经用来触发产生二级联动的javascript了
upload.asp
直接用的艾恩无组件上传程序
<!--#include file="UpLoad_Class.asp"-->
<%
dim upload
set upload = new AnUpLoad
upload.Exe = "jpg|bmp|jpeg|gif|png"
upload.MaxSize = 2 * 1024 * 1024 '2M
upload.GetData()
if upload.ErrorID>0 then
response.Write upload.Description
else
dim file,savpath
savepath = "upload"
set file = upload.files("file1")
if not(file is nothing) then
set result = file.saveToFile(savepath,0,true)
if not result.error then
response.Write "文件'" & file.LocalName & "'上传成功,保存位置'" & server.MapPath(savepath & "/" & file.filename) & "',文件大小" & file.size & "字节"
else
response.Write file.Exception
end if
end if
end if
set upload = nothing
%>
然后我在upload.asp里加入了request.form("distinction")语句之后就不能正确运行了(多运行几次之后服务器上出现不能调用request.form的调试警告)
但是如果不要上传的代码,upload.asp直接为
<%
temp=request.form("distinction")
response.write(temp)
%>
则可以完美执行
请问应如何修改?
------解决方案--------------------
在这个之前加判断
<!--#include file="UpLoad_Class.asp"-->
eg:
<% if(request.form("distinction")!= empty %>