Connecting Tech Pros Worldwide Help | Site Map

Displaying Selected Drop Down Box

Site Addict
 
Join Date: Aug 2008
Location: United States
Posts: 769
#1: Sep 15 '08
Hey Everyone,

Well this is probably a pretty easy question, but for some reason i just can not figure it out.

What i am trying to do is redisplay what was entered previously. I have figured everything out except for this drop down box.

Right now i am using one cfoutput query to display in the drop down box the values for it that are in the database. However, now i created a second query to display what was entered previously. The thing is i know i can't use 2 cfquery outputs around the same drop down box an so i was wondering how would i make the drop down box still have the options in the drop down box but also show what was previously selected?

here is what i have

Expand|Select|Wrap|Line Numbers
  1. this gets the values for the status
  2. <cfquery name="getstatus" datasource="CustomerSupport">
  3. usp_CS_getTicketStatuses
  4. </cfquery>
  5.  
  6. this is to display what was selected
  7. <cfquery name="ticket" datasource="CustomerSupport">
  8.         SELECT pk_ticketID,title,priority,
  9.                               status,cost_center,fk_customer_number,
  10.                               customer_company,customer_Fname,customer_Lname,
  11.                               customer_add1,customer_city,customer_state,
  12.                               customer_zip,customer_email,customer_pri_phone,
  13.                               customer_sec_phone,customer_notes,htpp 
  14.                 FROM dbo.tbl_CS_ticketMaster
  15. </cfquery>
  16.  
  17. <select name="status">
  18. <option value="" selected>Make A Selection</option
  19. >
  20. <cfoutput query="getstatus"><option value="#pk_status#"<cfif #pk_status# is #status#>selected</cfif>>#status_display#</option>
  21. </cfoutput>
  22.  
Thank you in advance,
Rach
Site Addict
 
Join Date: Aug 2008
Location: United States
Posts: 769
#2: Sep 15 '08

re: Displaying Selected Drop Down Box


solved the problem to my own question, Thank you :)
Rach
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Sep 15 '08

re: Displaying Selected Drop Down Box


Can you post the solution for the benefit of others. Thanks.
Site Addict
 
Join Date: Aug 2008
Location: United States
Posts: 769
#4: Sep 16 '08

re: Displaying Selected Drop Down Box


Hey Acoder,

Here was my solution

Expand|Select|Wrap|Line Numbers
  1. <cfoutput query="ticket">
  2. <cfset status = #status#>
  3. </cfoutput>
  4. *Status<select name="status">
  5. <option value="" selected>Make A Selection</option
  6. ><cfoutput query="getstatus"><option value="#pk_status#"<cfif #pk_status# is #status#>selected</cfif>>#status_display#</option>
  7. </cfoutput>
  8. </select>
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Sep 16 '08

re: Displaying Selected Drop Down Box


Thanks for posting the solution. You could also use #ticket.status#.
Reply