-
passing Session variables in Form
This has to do with a shopping cart system that I do not have complete control
of. The scenario is an executable using html templates which I can alter.
But I have no control of when or if the html pages are called.
When an item is ordered I create a Session variable for it:
<%
If InStr("<!Name>","Railroad") Then Session("rms") = 1
If InStr("<!Name>","Switching") Then Session("swadv") = 1
If InStr("<!Name>","Traffic") Then Session("tplan") = 1
If InStr("<!Name>","City") Then Session("city") = 1
%>
When it's deleted I set the variable to zero:
<%
If InStr("<!Name>","Railroad") Then Session("rms") = 1
If InStr("<!Name>","Switching") Then Session("swadv") = 1
If InStr("<!Name>","Traffic") Then Session("tplan") = 1
If InStr("<!Name>","City") Then Session("city") = 1
%>
But if it's never ordered then the Session variable just doesn't get created
at all, and therein lies the problem.
On the last page before I leave the server (and the Session) I put those
variables into a form:
<form method=post action="http://w.../Download.asp">
<% cntr = 0
cntr = Session("rms") %>
<input type=hidden name="rms" value=<%= cntr %>>
<% cntr = Session("swadv") %>
<input type=hidden name="swadv" value=<%= cntr %>>
<% cntr = Session("tplan") %>
<input type=hidden name="tplan" value=<%= cntr %>>
<% cntr = Session("city") %>
<input type=hidden name="city" value=<%= cntr %>>
<input type=submit value=" Click to continue ">
</form>
Then in the target (Download.asp) file I use the form variables:
<%
If Request.Form("rms") > 0 Then
Response.Write("<a href=%22http://myurl/rms3.exe%22>Click here to download
RMS</a><br>")
End If
If Request.Form("swadv") > 0 Then
Response.Write("<a href=%22http://myurl/swadv.exe%22>Download Switching Advisor</a><br>")
End If
If Request.Form("tplan") > 0 Then
Response.Write("<a href=%22http://myurl/tplan.exe%22>Download Traffic Planner</a><br>")
End If
If Request.Form("city") > 0 Then
Response.Write("<a href=%22http://myurl/citycrew.exe%22>Download City Crew
orders</a><br>")
End If
%>
There are two problems:
1. If the item in question was never ordered, and the Session variable never
created, I get an error in the Response.Write line for that item:
Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: ""]'
(The line executes properly if the item was ordered.)
2. The url in the output is fubar: it is doubled, with the local url followed
by the correct url.
Sorry for the verbosity. Can you point me in the right direction?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks