Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload page with validation does not work. Pls help.

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have an upload (uploadfile_form.asp) page with 4 elements - 2 select boxes, one input type = "file" and a submit (image) button.

First select box is populated from an Access DB .
On change of 1st select box (onChange="document.thisform.submit();">), I resubmit the form to populate the 2nd based on the value of 1st select box (requery same DB) .

3rd element is an input type="file", and I navigate to the file to be uploaded.
4th element is a submit (image) button, that will validate if 1st and 2nd select boxes are populated and then upload my selected file to the database.
Because of this enctype="multipart/form-data", my form does not get re-submitted to (onChange="document.thisform.submit();">) to populate the 2nd select box.
Any suggestions, recommendations and fixes will be greatly appreciated.

<SCRIPT language = "JavaScript">
<!--
function Run_OnClick()
{
var Opt1 = document.thisform.Opt1.value;
var Opt2 = document.thisform.Opt2.value
if (Opt1 == "" || Opt1 == "")
{
alert("Please make valid selection from dropdown.")
return false
}
else
{
url = "uploadfile1.asp?Opt1=" + Opt1 + "&Opt2=" + Opt2;
alert(url)
document.thisform.action = url;
document.thisform.submit();
//location.href=url
}
}

//-->
</SCRIPT>

<form name="thisform" action="uploadfile_form.asp" method="post" enctype="multipart/form-data">
<%
......
Option1: <SELECT name = "Opt1" onChange="document.thisform.submit();">
<OPTION>
<%
while not rs.eof
if rs("opt1") = opt1 then
%>
<OPTION value="<%=rs("opt1")%>" selected><%=rs("opt1")%>
<%
else
%>
<OPTION value="<%=rs("opt1")%>"><%=rs("opt1")%>
<%
end if
rs.movenext
wend
%>
</SELECT>
............
Option2: <SELECT name = "Opt2"'>
<OPTION>
<%
while not rs2.eof
%>
<OPTION value="<%=rs2("opt2")%>"><%=rs2("opt2")%>
<%
rs2.movenext
wend
%>
</SELECT>
............
<input name="file1" type="file" size="25"></td>
<input type=image src=<%=bupload%> id=upload name=upload onClick="Run_OnClick();return false">
 
can you write it in .aspx ??

upload components are easier with .net and none of the annoying multipart rubbish.

 
Unfortunately, I can't. I do not have any clue about .aspx and can not learn it within the time alloted me to finish this project.
 
There are several pure ASP uploads out there. The good ones will parse not just the file contents, but also the contents of the other form inputs so you can re-use them.

The encoding type should not affect whether your form is actually posted or not.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top