***I most definitely think VBScript is easier, but I'm learning....
AnyWHO, it's not working. I've been at it for a couple of hours this morning and it's still doing the same thing. (No message box appears when I hit the submit button, just goes on to the "Page cannot be displayed" And it gives me this error:
Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: -1]'
/wwwroot/testecp/postNew1.asp, line 271
Which is due to me not selecting a filename.
It shows a little error caution sign at the bottom left hand corner of the screen (when I press the back button). It says I have a syntax error on Line 19, Char 2, Code 0 (no clue what that means-- the code 0 part) on the PostNew1.asp page. This only occurs when I press the back button.
Now this is what I have....
PostNew1.asp
<%
if Session("UserID") = "" then
Response.Redirect("index1.asp")
end if
%>
<%
if Session("UserType") <> "originator" then
Response.Redirect("noPostNew1.asp")
end if
%>
<html>
<head>
<title>Post New ECP/IMI Impact Form</title>
<script language="javascript">
<!--
function checkData(){
if (document.myForm.ecpFilename.value.length !== 0 ) {
alert("Sending data...");
form.submit
return true;
}
}
else {
alert("missing file");
return false;
end if
}
}
end function
-->
</script>
</head>
[...code...]
'start of form--so u can see how it's name, etc.
<form name="myForm" method="post" action="postNew1.asp" enctype="multipart/form-data">
[...code...]
'The following is where the filename is located at on the form
ECP Filename
</td>
<td width="550" colspan = "11">
<input type="file" name="ecpFilename" size="60">
<br>
(Please ensure the adobe filename
does not have spaces.
You may use underscores.)
[...code...]
'I posted the following code also because this is the reason for me getting the error when I do not select a filename... Thought maybe I need to be adding my script down there somewhere instead. ?
<%
set o = new clsUpload
if o.Exists("submitButton") then
'get client file name without path
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
'Upload filename
o.FileInputName = "ecpFilename"
o.FileFullPath = Server.MapPath(".") & "\ecpFiles\" & sFile
o.save
'If not error redirect to complete message
if o.Error = "" then
Dim pSQLStatement, pConnection
Dim pRS, objMail
Dim pEcpNumber, pEcpTitle, pEcpFilename, pEcpOriginator, pEcpDateDistributed, pEcpDateDue
pEcpNumber = o.ValueOf("ecpNumber")
pEcpTitle = o.ValueOf("ecpTitle")
pEcpFilename = sFile
pEcpOriginator = o.ValueOf("ecpOriginator")
pEcpOriginator = Session("UserFullName")
pEcpDateDistributed = CStr(date())
pEcpDateDue = CStr(o.ValueOf("ecpDateDue"))
pConnection = "Provider=SQLOLEDB.1;UID=sa;PWD=;Initial Catalog=ecpDatabase2SQL;Data Source=localhost"
Set pRS = server.CreateObject("ADODB.RecordSet")
pRS.open "INSERT INTO ecpForms (ecpNumber, ecpTitle, ecpFilename, ecpOriginator, ecpDateDistributed, ecpDateDue) VALUES ('" & pEcpNumber & "', '" & pEcpTitle & "', '" & pEcpFilename & "', '" & pEcpOriginator & "', '" & pEcpDateDistributed & "', '" & pEcpDateDue & "') ", pConnection
[...code...]
Thanks for all your help

misskaos99
Quote:
quote:Originally posted by dparsons
I would actually use javascript for this (simply because I am more accustom to using it to validate client side and, to be 100% honest, have never used VBScript client side)
<script language=javascript>
<!--
function checkData(){
if (document.formname.ecpFilename.value.length == 0) {
alert("Please select a Form to work with!\n");
return false;
}
}
-->
</script>
in your form tag add something like this
<form name="myForm"> and the js line will become this:
document.myForm.ecpFilename.value.length == 0
*Remember* javascript is CASE SENSITIVE, so make sure you spell your form fields correctly!
hth.
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
Toni Burgess
misskaos99@yahoo.com