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
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
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

691 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