Solved

ASP Listbox showing stored value

Posted on 1999-01-06
5
228 Views
Last Modified: 2013-12-25
Using ASP, HTML and Vbscript, I have a listbox that successfully updates a database with the value chosen (code shown below).

<%
Dim strSex
strSex = Session("Sex")
%>

<td>Sex:</td>
      <td><select name="Sex" size="1">
        <option value="Male">Male</option>
        <option value="Female">Female</option>
        <option value="N/R">N/R</option>
      </select></td>

This works fine, but how do I get the List Box to display the present choice from the database, in situations where the user is editing the record.

I have already retrived the value and placed it in a variable named strSex but cannot get the List box to recognise the existing value.  The problem this is causing is that the user can select a value, update the database, but when they choose to edit the record again, the list box is showing the default value, NOT the database value, which is subsequently written to the database.

Any help would be MUCH appreciated as I am new to ASP.
0
Comment
Question by:cmsajon1
  • 3
5 Comments
 

Author Comment

by:cmsajon1
ID: 1857774
Edited text of question
0
 

Author Comment

by:cmsajon1
ID: 1857775
Adjusted points to 300
0
 

Expert Comment

by:cmsrrent
ID: 1857776
Maybe it would help if you did an Accurate Conceptual model for your system ?
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 300 total points
ID: 1857777
<td>Sex:</td>
      <td><select name="Sex" size="1">
        <option value="Male"<% if strSex="Male" then %> SELECTED<%End If%>>Male</option>
        <option value="Female""<% if strSex="Female" then %> SELECTED<%End If%>>Female</option>
        <option value="N/R""<% if strSex="N/R" then %> SELECTED<%End If%>>N/R</option>
      </select></td>
0
 

Author Comment

by:cmsajon1
ID: 1857778
Works superb, thanks very much !
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Firebug on Firefox 50 2 138
Responsive Design or Mobile Sites? 4 31
Help with query 3 26
Syntax for query to update table 2 15
Read about why website design really matters in today's demanding market.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

832 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