Solved

update using an option drop down list

Posted on 2002-07-22
5
139 Views
Last Modified: 2013-12-24
I have the following option selection drop down list:

<select name=keyword1 size=1>
<option name="keyword1" VALUE="#Trim(keyword1)#"></option>

<cfoutput query="keywords">
<option name="keyword1" value="#bookkeyword#" Selected>#bookkeyword#</option>
</cfoutput>

</select>

This allows me to select a keyword and add it to a database.  I now want to create an update or edit form that enables me to see what keyword was previously selected and change it if necessary.  I am having difficulty finding the proper code to set the keyword in the current option list so I can see what it was previously and then allow me to change it, subsequently passing it back to the database for updating.  I would appreciate help.

Can you also tell me how I can set this select list to initally show the first value in the list when a previous keyword has not been saved in the database table or when the keyword is being selected for the first time?

0
Comment
Question by:gcassel
[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
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 100 total points
ID: 7170358
Sounds like what you are looking for is this....

<select name=keyword1 size=1>
<option VALUE="#Trim(keyword1)#"></option>

<cfoutput query="keywords">
<option value="#bookkeyword#" <CFIF bookkeyword eq keyword1>SELECTED</CFIF>>#bookkeyword#</option>
</cfoutput>

</select>
0
 
LVL 15

Expert Comment

by:danrosenthal
ID: 7170361
This will select the current value and if no value is set, then the default will be the first value.

You should take out the line "<option VALUE="#Trim(keyword1)#"></option>" it is not necessary.
0
 

Author Comment

by:gcassel
ID: 7170644
Thanks. I think this is what I want but I keep getting the error message:
"An error occurred while evaluating the expression:
 bookkeyword eq keyword1
Error near line 146, column 48.
Error resolving parameter KEYWORD1"
   My list of keywords comes from a cfquery called "keywords" but the actual data that I am trying to edit and update is stored in a table called "Books".  I have a cfquery therefore on this page called "Book" because it pertains to all of the information about one particular book in the Books Table (based on the BookID passed to this page by a previous page where the book that we want to edit was chosen from a list of all books). The "keyword1" here is therefore a keyword for the particular book chosen and on this page it is from the cfquery, "Book". "BookKeyword" on the other hand comes from the cfquery, "keywords".
  The use of the drop down option box all seems pretty basic and presenting a value for editing from an existing record also seems like it should not be too hard.  Unfortunately though the formatting of this output type is confusing to me.  I appreciate your patience and help.


0
 
LVL 15

Expert Comment

by:danrosenthal
ID: 7170658
You seem to be very close.  The way you would call that variable is #book.keyword1#, without actual code to work with, all I can offer is the following:

<CFQUERY name="book" .....>
SELECT keyword1 .....
</CFQUERY>

<CFQUERY name="keywords" .....>
SELECT bookkeyword .....
</CFQUERY>

<cfoutput query="keywords">
<option value="#bookkeyword#" <CFIF bookkeyword eq book.keyword1>SELECTED</CFIF>>#bookkeyword#</option>
</cfoutput>
0
 

Author Comment

by:gcassel
ID: 7170808
Bingo!  Thanks.  I didn't realize you can call the query value without a cfoutput.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 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