Solved

ASP Listbox showing stored value

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 learn how to dynamically set the form action using jQuery.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now