Session variable and dropdown list

I am trying to get the dropdownlist to remember the last used value, which is stored in a session variable called 'sRegion.

Why does the following not work?

<td width="10%"><b><font size="2">Region</font></b></td>
<td width="20%"><font size="2"><select name="cboregion" size="1">
<option selected="selected"><%=Session("sRegion")%></option>
<option value="1">CEMA</option>
<option value="2">RA</option>
<option value="3">RAM</option>
<option value="4">UK</option></select></font>
<img border="0" src="images/portal_button_wht.gif" alt="Reuters regions. CEMA=Europe, RA=Asia, RAM=Americas, UK=United Kingdom" align="middle"></td>
LVL 1
citysideAsked:
Who is Participating?
 
rockymageeCommented:
If the stored procedure is working, here are a few things I would try:

' FIRST BEFORE THE SELECT USE THIS
' TO BE SURE THE SESSION IS HOLDING THE CURRENT VALUE
<% Response.Write Session("sRegion") %>

' THEN IN THE FIRST OPTION OF THE SELECT
<option selected value="<% =Session("sRegion") %>"><% =Session("sRegion") %></option>

' IF THE cboregion IS BEING REFERENCED FROM A PREVIOUS PAGE
<% Session("sRegion") = Request("cboregion") %>   ' WITHOUT THE .Form

Let me know ...
0
 
rockymageeCommented:
<select name="cboregion" size="1">
  <option selected="selected"><%=Session("sRegion")%></option>
  <option value="1">CEMA</option>
  <option value="2">RA</option>
  <option value="3">RAM</option>
  <option value="4">UK</option>
</select>

Can you share the code you use to save the "sRegion" data into the session variable.
My guess is that it is not being stored properly.

Does the value get stored when the form is submitted or maybe you need to add an onChange function to your dropdown that will replace the session variable with the new selected value when the user selects a new option.

0
 
citysideAuthor Commented:
The called page includes:

Session("sRegion") = Request.Form("cboregion")


The session variable is used later on this page as a parameter for a stored procedure so it must be stored correctly.

0
 
citysideAuthor Commented:
FIRST BEFORE THE SELECT USE THIS
' TO BE SURE THE SESSION IS HOLDING THE CURRENT VALUE
<% Response.Write Session("sRegion") %>
Already done that. It does show the value.
Will try the other 2 options and let you know.
0
 
rockymageeCommented:
Any Luck?
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.