Solved

update using an option drop down list

Posted on 2002-07-22
5
133 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
  • 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

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

937 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now