Pass Entire Contents of Combo Box in Session in Classic asp

I have a form which posts Search criteria to another asp page to display a Confirmation of selected values.
One of my objects is a combo box, pre-filled with the available selections from the logged on user's profile.
I have a default value of a blank OPTION tag and, if chosen, I would like to pass the rest of the list of values to the next page as comma-separated values.  
I cant get this part working.

Maybe I should use a different type of control - possibly a listbox;
Anyway, if a single selection is chosen, that value is passed to the next page and this part is working.
Attached is my code so far -
ive attached the form submit code and the small section that receives the session variable:

and a screen shot of the values passed from page to page:
I can get one value to pass correctly but how can I pass multiples with a default value of spaces?
thanks
john
 1.jpg 2.jpg
search.asp:

FinancialTrackingCodes=session("FinancialTrackingCodes")
	FinancialTrackingDescription=session("FinancialTrackingDescription")
	firstpass =true

	if ubound(FinancialTrackingCodes)>0 then
			Response.write "<select name=""sProgramNumber"" size=1><option></option>"
		for i =1 to ubound(FinancialTrackingCodes)-1
			Response.write "<OPTION VALUE='"& FinancialTrackingCodes(i)&"'>"
								if instr(1, session("sProgramNumber"), FinancialTrackingCodes(i),1)  then response.write "'selected>"
					Response.write FinancialTrackingCodes(i) & " - " & FinancialTrackingDescription(i) & "</option>" & vbcrlf
		next
		Response.write "</select>"
	else
		Response.write "No Records Found"

	end if

	Response.write "<input type=hidden name=""sAgency_code"" value=""" & session("AgencyCodes")(0) & " - " & session("AgencyTitles")(0) & """>"
	Response.write "</td>"
	Response.write "</tr>"
--------------
reportsortby.asp:
	<%if session("sProgramNumber") <> "" then %>
		<INPUT type="text" name="program" value="<%response.write Replace(Replace(Trim(session("sProgramNumber")),"'",""),", ",",") %>" />
   <%end if %>

Open in new window

jtrapat1Asked:
Who is Participating?
 
nschaferConnect With a Mentor Commented:
OK, I'm not sure where session("sProgramNumber") is being defined, but so long as the IF statement is working for you then the following should work.

Since you already have the Financial Tracking Codes in an array stored in a session variable we can just use the join function to turn the array into a comma delimited string.

Hope this helps,

Neal.
<%if session("sProgramNumber") <> "" then %>
    <INPUT type="text" name="program" value="<%response.write request("sProgramNumber") %>" />
<%else%>
    <INPUT type="text" name="program" value="<%response.write join(session("FinancialTrackingCodes"),",") %>" />
<%end if %>

Open in new window

0
 
sybeCommented:
First of all a Session object isn't meant to pass values from one page to another. It is meant to store user-variables which are valid for the complete session. That includes all tabs and windows the user might have open simultaneously.

Passing values from one page top another can be done with the Request object (Form, Querystring).

Then I do not understand why you want to pass non-selected options in a dropdown to the next page, if you can retrieve them from the users profile. Why don't you retrieve them again from the users profile?
0
 
jtrapat1Author Commented:
OK- Thanks
Ill try the request object;
I'll try to explain more in detail.
I cant get the syntax down to pass either: all options in the list OR a single selection.
Maybe you are right-
but I cant seem to retrieve the values again on the following page;
they are set at the initial logon page and I cant get them to display on the page.
do you know the syntax OR could i just replace the session with request?
thanks
john
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
nschaferCommented:
As Sybe stated, you could simply pull these values from the user profile again, however if you don't want to do that for some reason than you can create a hidden input with a comma delimited list of the values.  

I'm a bit confused by your code.  Is the Search.asp file the one you are trying to pass the data from?  It appears that you already have the data in an array stored in a session variable.  (Assuming we're talking about the FinancalTrackingCodes).  

Neal.
0
 
jtrapat1Author Commented:
nschafer-
thanks for the help-
im having trouble trapping the data to display on a confirmation page: the reportsortby.asp
I dont know how to reference this on the following page.
Ideally, i would like to use this logic after the page is submitted with the search criteria:
If an FTC is selected, pass that one;
else pass the entire comma separated list of codes;
I can trap the single FTC code - but when nothing is selected - the followup page displays a blank:
so in "View Source" on the confirm page -
this is displayed:
                     <INPUT type="text" name="org2" value="01050" />
      <INPUT type="text" name="program" value="" />
      <INPUT type="text" name="category_code" value="E" />

I would like to have the codes displayed like this -
<INPUT type="text" name="program" value="'LU,SA,RP" />
where these three codes are from the initial combo box selection-
attached is my syntax which isnt doing what id like:
Its like I cant trap this array of codes at all.


thanks
john

<%if session("sProgramNumber") <> "" then %>
		<INPUT type="text" name="program" value="<%response.write request("sProgramNumber") %>" />
    <%else%>
  		<INPUT type="text" name="program" value="<%response.write Replace(Replace(Trim(request("sProgramNumber")),"'",""),", ",",") %>" />
    <%end if %>

Open in new window

0
 
jtrapat1Author Commented:
nschafer-
thanks for the tremendous help;
i know it seemed like a small problem but in going back and modifying someone elses 10 year old code- it helped greatly.

thanks
again john
0
 
nschaferCommented:
Glad I could help.

Neal.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.