home *** CD-ROM | disk | FTP | other *** search
ColdFusion Markup Language | 2002-03-18 | 2.1 KB | 68 lines |
- "">
- <cfparam name="attributes.delimiter" default=",">
-
- <cfif not isDefined("attributes.values")>
- <cfthrow message="cfselectbox must define values attribute.">
- </cfif>
- <cfif isDefined("attributes.labels") and listLen(attributes.labels,attributes.delimiter) is not listLen(attributes.values,attributes.delimiter)>
- <cfthrow message="form:selectbox: If you pass labels, it must have the same number of elements as the values attributes.">
- </cfif>
- <cfparam name="attributes.labels" default="#attributes.values#">
-
- <!---
- Simple logic - if form.NAME exists, we must have
- submitted the form - so use that value, otherwise
- use the optional defaultValue parameter
- --->
- <cfif isDefined("form.#attributes.name#")>
- <cfset value = form[attributes.name]>
- <cfelse>
- <cfset value = attributes.defaultValue>
- </cfif>
-
- <!--- render control --->
- <cfoutput><select name="#attributes.name#"</cfoutput>
-
-
- <!--- Every other argument is optional, so we can just dump it on --->
- <cfloop item="arg" collection="#attributes#">
- <cfif not listFind("name,defaultValue,delimiter,values,labels",arg)>
- <cfoutput> #arg#="#attributes[arg]#"</cfoutput>
- </cfif>
- </cfloop>
-
- <cfoutput>>
- </cfoutput>
-
- <!--- now handle options --->
- <cfloop index="i" from=1 to="#listLen(attributes.values,attributes.delimiter)#">
- <cfset val = listGetAt(attributes.values,i,attributes.delimiter)>
- <cfset label = listGetAt(attributes.labels,i,attributes.delimiter)>
- <cfoutput><option value="#val#" <cfif val is value>selected</cfif>>#label#</option>
- </cfoutput>
- </cfloop>
-
- <cfoutput></select></cfoutput>
- <cfsetting enableCFOutputOnly=0><cfsetting enableCFOutputOnly=1>
- <!---
- **
- * CFMX Example Applications
- *
- * Copyright (c) 2002 Macromedia. All Rights Reserved.
- *
- * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
- * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
- *
- **
- --->
-
- <!---
- Displays a submit button. The name will automatically be based on the
- form name.
- --->
-
- <cfif not listFindNoCase(getBaseTagList(),"cf_main")>
- <cfthrow message="form:submit must be wrapped in form:main tags.">
- </cfif>
-
- <cfset parent = g