MakeSelectList(name, displayList[, defaultSelected][, valueListSTR][, delimiter][, mutliple][, size])
Last updated June 21, 2002
Version: 2 | Requires: CF5 | Library: UtilityLib
Description:
Creates a Select form item populated with given string items.
Return Values:
Returns a string.
Example:
<CFOUTPUT>
<FORM ACTION="">
Day of Week: #MakeSelectList("DOW",
"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",
DateFormat(Now(),"dddd"),"1,2,3,4,5,6,7")#
</FORM>
</CFOUTPUT>
Parameters:
Name | Description | Required |
---|---|---|
name | The name of the Select item. | Yes |
displayList | The text values for the drop down. | Yes |
defaultSelected | The selected item. | No |
valueListSTR | The values for the drop down. Defaults to displayList. | No |
delimiter | The delimiter to use for all lists. | No |
mutliple | Turns on multiple for the drop down. Default is false. | No |
size | Size of the drop down. | No |
Full UDF Source:
/**
* Creates a Select form item populated with given string items.
* Mods by RCamden and Grant Furick.
*
* @param name The name of the Select item. (Required)
* @param displayList The text values for the drop down. (Required)
* @param defaultSelected The selected item. (Optional)
* @param valueListSTR The values for the drop down. Defaults to displayList. (Optional)
* @param delimiter The delimiter to use for all lists. (Optional)
* @param mutliple Turns on multiple for the drop down. Default is false. (Optional)
* @param size Size of the drop down. (Optional)
* @return Returns a string.
* @author Seth Duffey (sduffey@ci.davis.ca.us)
* @version 2, June 21, 2002
*/
function MakeSelectList(name, displayList) {
var outstring = "<select name=""#name#""";
var defaultSelected = "";
var valueListSTR = displayList;
var delimiter = ",";
var i = 1;
if(arrayLen(arguments) gt 2) defaultSelected = arguments[3];
if(arrayLen(arguments) gt 3) valueListSTR = arguments[4];
if(arrayLen(arguments) gt 4) delimiter = arguments[5];
if(arrayLen(arguments) gt 5 AND arguments[6]) outstring = outstring & " multiple";
if(arrayLen(arguments) gt 6) outstring = outstring & " size=#arguments[7]#";
outstring = outstring & ">";
for (i=1; i LTE listLen(displayList,delimiter); i=i+1) {
outstring = outstring & "<option value=""#listGetAt(valueListSTR,i,delimiter)#""";
if(defaultSelected eq listGetAt(valueListSTR,i,delimiter)) outstring = outstring & " selected";
outstring = outstring & ">#listGetAt(displayList,i,delimiter)#</option>";
}
outstring = outstring & "</select>";
return outstring;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016