[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP Listbox showing stored value

Posted on 1999-01-06
5
Medium Priority
?
239 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 1200 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

831 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