Solved

ASP Listbox showing stored value

Posted on 1999-01-06
5
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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