View Full Version : Binding a Select Item

01-28-2008, 05:26 PM
Hi Guys,
I have a select menu with various items. I'd like to bind whatever selection the user makes to a session variable, so if he goes to another page and decides to comeback for any reason, the selected item is still there.

I tried it the same as with any text field but there is no option to bind to Input.Value for a Select menu item.


01-28-2008, 06:01 PM
what you coding this in?

and is the value from the dropdown submitted and stored to a db before moving to the next page

01-28-2008, 07:11 PM
Thanks Davidj for the reply.

Coding Classic ASP. It is in a form where all the submitted values pass to a preview page. No DB involved.

Should you need any more details please let me know :)


01-29-2008, 05:43 AM
in the option tag i use a strcmp (string compare) function in php

im not sure what you can use in asp but i can give you some pseudo php code which could give you an idea if your into coding you should understand this

// catch the value in a session
$_SESSION['option'] = $_POST['dropdown'];

<option value="val1" <?php if($_SESSION['option'] == "val1"){echo "selected";} ?>>value1</option>
<option value="val2" <?php if($_SESSION['option'] == "val2"){echo "selected";} ?>>value2</option>
<option value="val3" <?php if($_SESSION['option'] == "val3"){echo "selected";} ?>>value3</option>