4 Replies - 1703 Views - Last Post: 02 April 2009 - 07:17 AM Rate Topic: -----

#1 chucky   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-April 09

List Box Question

Posted 02 April 2009 - 05:37 AM

I was trying to use the listbox code in the post from skyhawk133 found here http://www.dreaminco...owtopic9256.htm

And I couldnt quite get it right. I get Invalid CFML construct found on line 260 at column 156. row 260 contains the CFSET strList.....

	   	<cfloop query="qryCustomers">
			<cfset CustomerName = Cust_Name>
													
							<cfset strListOfCustomers = strListOfCustomers & "<option value='#CustomerName#' <cfif (isDefined("form.strCustomerList")) AND (ListFind(strSelectedCustomers, CustomerName) NEQ "0")>SELECTED</cfif>>#CustomerName# </option>">
				
	   </cfloop>




Any ideas? Thanks!!!

Is This A Good Question/Topic? 0
  • +

Replies To: List Box Question

#2 sansclue   User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: List Box Question

Posted 02 April 2009 - 06:01 AM

View Postchucky, on 2 Apr, 2009 - 04:37 AM, said:

<cfset strListOfCustomers = strListOfCustomers & "<option value='#CustomerName#'....>


You seem to be doing some sort of string concatenation, rather than just generating an html select list. Can you elaborate on what you are trying to do?
Was This Post Helpful? 0
  • +
  • -

#3 chucky   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-April 09

Re: List Box Question

Posted 02 April 2009 - 06:04 AM

View Postsansclue, on 2 Apr, 2009 - 05:01 AM, said:

View Postchucky, on 2 Apr, 2009 - 04:37 AM, said:

<cfset strListOfCustomers = strListOfCustomers & "<option value='#CustomerName#'....>


You seem to be doing some sort of string concatenation, rather than just generating an html select list. Can you elaborate on what you are trying to do?



I am trying to generate a list box and retain any selections from the previous submission.
Was This Post Helpful? 0
  • +
  • -

#4 sansclue   User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: List Box Question

Posted 02 April 2009 - 07:01 AM

View Postchucky, on 2 Apr, 2009 - 05:04 AM, said:

I am trying to generate a list box and retain any selections from the previous submission.


Then you don't need the string concatenation. Assuming your field supports multiple selections, the selected values will be passed as a comma delimited list. So you can use the listFindNoCase function to determine which values were already selected. The syntax is very simple:

<!--- 
where form.selCustomers is the name of your form field, and
CustomerName is the name of a column in your query 
--->
 <cfif listFindNoCase(form.selCustomers, CustomerName)>selected</cfif>



Then just plug that statement into your <option> tag:

<!--- ensure the field is always defined --->
<cfparam name="form.selCustomers" default="">
...

<select ...>
<cfoutput query="yourQuery">
<option value="#CustomerName#" <cfif listFindNoCase(form.selCustomers, CustomerName)>selected</cfif>>#CustomerName#</option>
</cfoutput>

</select>


Was This Post Helpful? 1
  • +
  • -

#5 chucky   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-April 09

Re: List Box Question

Posted 02 April 2009 - 07:17 AM

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1