?
Solved

Pass Entire Contents of Combo Box in Session in Classic asp

Posted on 2011-02-10
7
Medium Priority
?
801 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:jtrapat1
  • 3
  • 3
7 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 34870670
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
 

Author Comment

by:jtrapat1
ID: 34870782
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
 
LVL 19

Expert Comment

by:nschafer
ID: 34871518
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:jtrapat1
ID: 34871723
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
 
LVL 19

Accepted Solution

by:
nschafer earned 2000 total points
ID: 34875120
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
 

Author Comment

by:jtrapat1
ID: 34876741
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
 
LVL 19

Expert Comment

by:nschafer
ID: 34878796
Glad I could help.

Neal.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question