Skip to main content
Participant
January 24, 2007
Question

retrieving data from sql with dropdown list. newbi at work

  • January 24, 2007
  • 2 replies
  • 244 views
Hello all, New at coldfusion and i am just looking for a little advice. I bought a well known publishers book about coldfusion and
it hasnt rerally helped with this particular problem!! so what it is i am using sql server 2005, and i am quite comfotable with that, what i am stuck on is that on my page i have a drop down list of cars, i have the basic retrieve statement for the database, how do i add to the retrieve statement the choice of the drop down list, the list also has a submit button?
This topic has been closed for replies.

2 replies

Inspiring
January 24, 2007
if your select element is in a form and the form is submitted, it will pass user's selection (to be exact, the value of the "value" attribute if you have it of select element) to the form's action page. on the action page you can get that value by #form.[name_of_your_select_element]#. you can use that in the "WHERE ..." clause of your query. don't forget to validate the passed value with cfparam or cfqueryparameter - always a good idea.

if in your question you meant that you want to pre-select an item in your select box based on user's selection elsewhere (i.e. on a previous page) - let me know and I will give you a few hints on how to do it.
Inspiring
January 24, 2007
The easiest way is with
<cfselect query="yourquery"
value="the id field"
display = "some other field">