Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

update using an option drop down list

Posted on 2002-07-22
5
Medium Priority
?
142 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 400 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

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 …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 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