Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Values & Session Variables

Status
Not open for further replies.

birmbear

Programmer
Mar 27, 2002
10
US
I'm butting my head against a wall, and it's starting to hurt!

I'd like my user to select an item from an option list. (Let's call it the skills list.) After they've selected an item, I'd like them to press a submit button that calls up another form that lists all the people in my database who have that skill.

To make this work, I've got a dynamically generated (from a recordset) option list. And I've got a session variable (svMemberSkillID) that I can use on the list page recordset that gets all the members who have that skill and displays their names.

What I need to get smart about is how -- and where -- to connect the session variable with the option item selected by my user.

Can anyone help me?

TIA,
__Birm
 
"What I need to get smart about is how -- and where -- to connect the session variable with the option item selected by my user."

What exactly are you trying to do? use the svMemberSkillID variable to select from your db?
Code:
<%
myVar = svMemberSkillID

strSelect = &quot;SELECT * FROM yourTable WHERE fldSkill = &quot; & myVar
%>

or have the skill preselected in a menu

use an if statement in the menu code

if myVar = option then response.write(&quot;selected&quot;)

Cheech

[Peace][Pipe]
 
When you submit your form the data in the select drop down goes with it, all you need to do is retrieve the form data on the 2nd page and run you statement from that.

first page
<form method=&quot;post&quot;>
<select name=&quot;mySelect&quot;>
<option value=&quot;asp&quot;>ASP</option>
<option ... etc

secoond page
dim myVar
myVar = Request.Form(&quot;mySelect&quot;)

sql = &quot;Select * from table where skills = '&quot;&myVar&quot;'&quot;

etc

hope this helps


 
Cheech...Thanks, but I'm not having problems with the SQL. What I'm having trouble with is knowing how to set the value of a session variable to the value of the item selected from my option list. Once I've got that session variable initialized with the value, I can use it in a SQL where clause and be on my way.

__Birm
 
Simon,
Thanks...I think you've almost answered my question.
Let's say that I have a session variable like &quot;svMyASP.&quot;

Further, let's say that I have an option list like this....
<form method=&quot;post&quot;>
<select name=&quot;mySelect&quot;>
<option value=&quot;asp_ID1&quot;>ASP1</option>
<option value=&quot;asp_ID2&quot;>ASP2</option>
<option value=&quot;asp_ID3&quot;>ASP3</option>
<option ... etc

How can I set a set the session variable to the selected option variable?

What I've tried is various permutations of
<%= Session(&quot;svMyASP&quot;) = Request.Form(&quot;mySelect&quot;).Value %>
But nothing seems to work.
What am I doing wrong?
Oh yes....I've got a DreamWeaver-generated behavior on the page. It uses a recordset to dynamically create the option list. I wonder if that might not be getting in my way?

Thanks again,
__Birm
 
Code:
<%= Session(&quot;svMyASP&quot;) = Request.Form(&quot;mySelect&quot;).Value %> should be <% Session(&quot;svMyASP&quot;) = Request.Form(&quot;mySelect&quot;).Value %>

Cheech


[Peace][Pipe]
 
I see the problem you have.

You want to find the option in your drop down and select it if it matches you session var. ?

if so then you need to find the loop that creates the drop down and add

<%if (session(&quot;svMyASP&quot;) = rs(&quot;whatever&quot;)) then%> selected
<%end if%>

this should make the correct option selected
you need to replace rs(&quot;whatever&quot;) with whatever recordset name and field name you are using.

hope this helps

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top