M
memiller
I have a hyperlink on an ASP page that calls another ASP page with the
code shown below. This page allows (forces) a user to select a file to
be uploaded, then should call a third ASP page that will do the actual
upload. What happens is I can enter a file name but the third page
doesn't get loaded. I see the upload page being called in the browser
when the alert message displays, but then it appears to reload this
page. What am I missing??? I should also note that the upload page
opens fine if I move the location.href command outside of the function
(for testing purposes).
<FORM NAME="GetFileName">
<script language=javascript>
function callImport(fieldName) {
// Read the value from the named field passed to this function
fileName = document.forms[0].elements[fieldName].value;
// Replace backslashes with forward slashes
fileName = fileName.replace("\\","/");
if (fileName.length > 0) {
location.href = "upload.asp";
alert("after page redirect");
}
else {
alert("You must provide a file name and path.");
}
}
</script>
<br>
<font face="Arial"><b>Select the file to load:</b></font>
<br><br>
<input type="file" name="fileName" size="60">
<br><br>
<input type=SUBMIT name="submitButton" value="Load File"
onClick="callImport('fileName')">
</form>
code shown below. This page allows (forces) a user to select a file to
be uploaded, then should call a third ASP page that will do the actual
upload. What happens is I can enter a file name but the third page
doesn't get loaded. I see the upload page being called in the browser
when the alert message displays, but then it appears to reload this
page. What am I missing??? I should also note that the upload page
opens fine if I move the location.href command outside of the function
(for testing purposes).
<FORM NAME="GetFileName">
<script language=javascript>
function callImport(fieldName) {
// Read the value from the named field passed to this function
fileName = document.forms[0].elements[fieldName].value;
// Replace backslashes with forward slashes
fileName = fileName.replace("\\","/");
if (fileName.length > 0) {
location.href = "upload.asp";
alert("after page redirect");
}
else {
alert("You must provide a file name and path.");
}
}
</script>
<br>
<font face="Arial"><b>Select the file to load:</b></font>
<br><br>
<input type="file" name="fileName" size="60">
<br><br>
<input type=SUBMIT name="submitButton" value="Load File"
onClick="callImport('fileName')">
</form>