Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pass Entire Contents of Combo Box in Session in Classic asp

Posted on 2011-02-10
7
Medium Priority
?
793 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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