home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / Coldfusion / coldfusion-60-win-en.exe / withflush.cfm < prev    next >
Encoding:
ColdFusion Markup Language  |  2002-03-18  |  2.1 KB  |  68 lines

  1. "">
  2. <cfparam name="attributes.delimiter" default=",">
  3.  
  4. <cfif not isDefined("attributes.values")>
  5.     <cfthrow message="cfselectbox must define values attribute.">
  6. </cfif>
  7. <cfif isDefined("attributes.labels") and listLen(attributes.labels,attributes.delimiter) is not listLen(attributes.values,attributes.delimiter)>
  8.     <cfthrow message="form:selectbox: If you pass labels, it must have the same number of elements as the values attributes.">
  9. </cfif>
  10. <cfparam name="attributes.labels" default="#attributes.values#">
  11.  
  12. <!---
  13.     Simple logic - if form.NAME exists, we must have
  14.     submitted the form - so use that value, otherwise
  15.     use the optional defaultValue parameter
  16. --->
  17. <cfif isDefined("form.#attributes.name#")>
  18.     <cfset value = form[attributes.name]>
  19. <cfelse>
  20.     <cfset value = attributes.defaultValue>
  21. </cfif>
  22.  
  23. <!--- render control --->
  24. <cfoutput><select name="#attributes.name#"</cfoutput>
  25.  
  26.  
  27. <!--- Every other argument is optional, so we can just dump it on --->
  28. <cfloop item="arg" collection="#attributes#">
  29.     <cfif not listFind("name,defaultValue,delimiter,values,labels",arg)>
  30.         <cfoutput> #arg#="#attributes[arg]#"</cfoutput>
  31.     </cfif>
  32. </cfloop>
  33.  
  34. <cfoutput>>
  35. </cfoutput>
  36.  
  37. <!--- now handle options --->
  38. <cfloop index="i" from=1 to="#listLen(attributes.values,attributes.delimiter)#">
  39.     <cfset val = listGetAt(attributes.values,i,attributes.delimiter)>
  40.     <cfset label = listGetAt(attributes.labels,i,attributes.delimiter)>
  41.     <cfoutput><option value="#val#" <cfif val is value>selected</cfif>>#label#</option>
  42.     </cfoutput>
  43. </cfloop>
  44.  
  45. <cfoutput></select></cfoutput>
  46. <cfsetting enableCFOutputOnly=0><cfsetting enableCFOutputOnly=1>
  47. <!--- 
  48. **
  49. * CFMX Example Applications
  50. *
  51. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  52. *
  53. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  54. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  55. *
  56. **
  57.  --->
  58.  
  59. <!---
  60.     Displays a submit button. The name will automatically be based on the 
  61.     form name.
  62. --->
  63.  
  64. <cfif not listFindNoCase(getBaseTagList(),"cf_main")>
  65.     <cfthrow message="form:submit must be wrapped in form:main tags.">
  66. </cfif>
  67.  
  68. <cfset parent = g