Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

List box

Posted on 2000-02-15
1
Medium Priority
?
141 Views
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.

0
Comment
Question by:rajasekaran
1 Comment
 
LVL 8

Accepted Solution

by:
xabi earned 200 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>
</select>
..
..
------------- 8< ---------- 8< --------

xabi
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

916 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