List box

Posted on 2000-02-15
Last Modified: 2010-04-09
i have a list box with 3 options
and by default nothing is selected.

i am accepting the option from the user and storing the value in a database.

But the problem is , how to set the default value as per the value in the database.  right now allways the first value is displayed even though i had saved with option 3 as the value.

Question by:rajasekaran
1 Comment

Accepted Solution

xabi earned 50 total points
ID: 2521995
Here goes the solution in asp, If you need it in other language just ask. Anyway it should be easy to port it into PHP or other language.

------------- 8< ---------- 8< --------
myvar = rs("field_name")%>
<select name="myselect>
  <option value="value1" <%if myvalue="value1" then response.write("selected") end if%>>Value1</option>
  <option value="value2" <%if myvalue="value2" then response.write("selected") end if%>>Value2</option>
  <option value="value3" <%if myvalue="value3" then response.write("selected") end if%>>Value3</option>
------------- 8< ---------- 8< --------


Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML &#0153 2 17
Input box gone wrong 8 24
Help to align the buttons in a row 2 27
CSS: How do I override in-line styling 11 15
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

776 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