• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

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>
0
cityside
Asked:
cityside
  • 3
  • 2
1 Solution
 
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
 
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
 
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

Featured Post

Independent Software Vendors: 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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now