Solved

update using an option drop down list

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
What You Need to Know when Searching for a Webhost Provider
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

761 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