Solved

ASP Listbox showing stored value

Posted on 1999-01-06
5
229 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

827 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