I am trying to call a sub within the current asp file (written with vbscript) but when I hit the submit button of my frontpage form, I see a quick flash of "Error On Page" in the status bar of IE, then the page reloads. This is something new I am trying so please see if you can spot my error(s) and help a newbie out.
Here's the code:
<html>
<head>
</head>
<%
Dim adoCon
Dim rsCoupon
Dim strSQL
Dim txtActionType
Dim lngID
Sub cmdTakeAction()
'for testing purposes - I just want to see the
'redirection work
Response.Redirect "Default.htm"
' Select Case txtActionType
' Case "Add","Edit"
' rsCoupon.Fields("Company Name") = FrontPage_Form1("CompanyName")
' rsCoupon.Fields("Coupon Description") = FrontPage_Form1("CouponDescription")
' rsCoupon.Fields("Hyperlink to JPEG") = FrontPage_Form1("HyperlinkToJPEG")
' rsCoupon.Fields("Start Date") = FrontPage_Form1("StartDate")
' rsCoupon.Fields("End Date") = FrontPage_Form1("EndDate")
' rsCoupon.Update
' Case "Delete"
' strSQL = "DELETE FROM Main WHERE Main.ID=" & lngID
' adoCon.Execute(strSQL)
' End Select
' rsCoupon.Close
' Set rsCoupon = Nothing
' Set adoCon = Nothing
End Sub
txtActionType = Request.QueryString("Action")
lngID = Request.QueryString("ID")
'Open connection
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("../fpdb/testcoupon.mdb")
Set rsCoupon = Server.CreateObject("ADODB.Recordset")
if txtActionType = "Add" then
strSQL = "SELECT Main.* FROM Main;"
rsCoupon.CursorType = 2
rsCoupon.LockType = 3
else 'txtActionType is Delete or Edit
strSQL = "SELECT Main.* FROM Main WHERE Main.ID=" & lngID
end if
rsCoupon.Open strSQL, adoCon
if txtActionType = "Add" then
rsCoupon.AddNew
rsCoupon("Start Date") = Date()
rsCoupon("Expiration Date") = DateSerial(Year(Date), Month(Date) + 1, Day(Date)) 'add a month to today
rsCoupon("Hyperlink to JPEG") = "ecoupons/"
end if
%>
<body onload="document.FrontPage_Form1.CompanyName.focus()"><form method="POST" name="FrontPage_Form1">
<h3 align="center"><% Response.Write(txtActionType) & " Coupon" %></h3>
<p align="center">Company Name
<input type="text" name="CompanyName" size="60" value = '<%Response.Write(rsCoupon("Company Name"))%>' tabindex="1"></p>
<p align="center">Coupon Description
<input type="text" name="CouponDescription" size="70" value = '<%Response.Write(rsCoupon("Coupon Description"))%>' tabindex="2"></p>
<p align="center">Hyperlink to JPEG
<!--webbot bot="Validation" s-display-name="Hyperlink to JPEG" s-data-type="String" b-allow-letters="TRUE" b-allow-digits="TRUE" s-allow-other-chars="/" --><input type="text" name="HyperlinkToJPEG" size="50" value=<%Response.Write(rsCoupon("Hyperlink to JPEG"))%> tabindex="3"></p>
<p align="center">Start Date
<input type="text" name="StartDate" size="10" value = '<%Response.Write(rsCoupon("Start Date"))%>' tabindex="4"></p>
<p align="center">Expiration Date
<input type="text" name="ExpirationDate" size="10" value = '<%Response.Write(rsCoupon("Expiration Date"))%>' tabindex="5"></p>
<p align="center">
<input type="submit" value="Submit" name="B1" tabindex="6" onclick="cmdTakeAction"></a><input type="reset" value="Reset" name="B2"></p>
</p>
</form>
<p align="center"></body>
</html>
Thank you!
Amy
Here's the code:
<html>
<head>
</head>
<%
Dim adoCon
Dim rsCoupon
Dim strSQL
Dim txtActionType
Dim lngID
Sub cmdTakeAction()
'for testing purposes - I just want to see the
'redirection work
Response.Redirect "Default.htm"
' Select Case txtActionType
' Case "Add","Edit"
' rsCoupon.Fields("Company Name") = FrontPage_Form1("CompanyName")
' rsCoupon.Fields("Coupon Description") = FrontPage_Form1("CouponDescription")
' rsCoupon.Fields("Hyperlink to JPEG") = FrontPage_Form1("HyperlinkToJPEG")
' rsCoupon.Fields("Start Date") = FrontPage_Form1("StartDate")
' rsCoupon.Fields("End Date") = FrontPage_Form1("EndDate")
' rsCoupon.Update
' Case "Delete"
' strSQL = "DELETE FROM Main WHERE Main.ID=" & lngID
' adoCon.Execute(strSQL)
' End Select
' rsCoupon.Close
' Set rsCoupon = Nothing
' Set adoCon = Nothing
End Sub
txtActionType = Request.QueryString("Action")
lngID = Request.QueryString("ID")
'Open connection
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("../fpdb/testcoupon.mdb")
Set rsCoupon = Server.CreateObject("ADODB.Recordset")
if txtActionType = "Add" then
strSQL = "SELECT Main.* FROM Main;"
rsCoupon.CursorType = 2
rsCoupon.LockType = 3
else 'txtActionType is Delete or Edit
strSQL = "SELECT Main.* FROM Main WHERE Main.ID=" & lngID
end if
rsCoupon.Open strSQL, adoCon
if txtActionType = "Add" then
rsCoupon.AddNew
rsCoupon("Start Date") = Date()
rsCoupon("Expiration Date") = DateSerial(Year(Date), Month(Date) + 1, Day(Date)) 'add a month to today
rsCoupon("Hyperlink to JPEG") = "ecoupons/"
end if
%>
<body onload="document.FrontPage_Form1.CompanyName.focus()"><form method="POST" name="FrontPage_Form1">
<h3 align="center"><% Response.Write(txtActionType) & " Coupon" %></h3>
<p align="center">Company Name
<input type="text" name="CompanyName" size="60" value = '<%Response.Write(rsCoupon("Company Name"))%>' tabindex="1"></p>
<p align="center">Coupon Description
<input type="text" name="CouponDescription" size="70" value = '<%Response.Write(rsCoupon("Coupon Description"))%>' tabindex="2"></p>
<p align="center">Hyperlink to JPEG
<!--webbot bot="Validation" s-display-name="Hyperlink to JPEG" s-data-type="String" b-allow-letters="TRUE" b-allow-digits="TRUE" s-allow-other-chars="/" --><input type="text" name="HyperlinkToJPEG" size="50" value=<%Response.Write(rsCoupon("Hyperlink to JPEG"))%> tabindex="3"></p>
<p align="center">Start Date
<input type="text" name="StartDate" size="10" value = '<%Response.Write(rsCoupon("Start Date"))%>' tabindex="4"></p>
<p align="center">Expiration Date
<input type="text" name="ExpirationDate" size="10" value = '<%Response.Write(rsCoupon("Expiration Date"))%>' tabindex="5"></p>
<p align="center">
<input type="submit" value="Submit" name="B1" tabindex="6" onclick="cmdTakeAction"></a><input type="reset" value="Reset" name="B2"></p>
</p>
</form>
<p align="center"></body>
</html>
Thank you!
Amy