Horizontal Scroll and Tool Tip in a select option form element.

Developers may sometimes want to have a horizontal scroll bar nested at the bottom of select option fields.

There is a way to encapsulate the select and option elements with a DIV tag.

<cfquery name="getDepartment" datasource="cfdocexamples">
SELECT Dept_ID,Dept_Name
FROM Departments
</cfquery>
<form>
<div style="overflow-x:scroll; width:200px; overflow: -moz-scrollbars-horizontal;">
<select name="thisSelectList" size="5">
<cfoutput query="getDepartment">
   <option value="#Dept_ID#" title="#Dept_Name#">#Dept_Name# &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
</cfoutput>
</select>
</div>
</form>

Validate a list of required fields using cfscript

// sethron begin validation of req_fields here
bFormErrlist = "";
if (isDefined("Form.req_fields") and LEN(Form.req_fields))
{
for (rqID=1; rqID LT listLen(Form.req_fields,","); rqID=rqID+1)
{rqName = ListGetAt(form.req_fields,rqID);
rqFormName = 'Form.' & ListGetAt(form.req_fields,rqID);
if (not isDefined(rqFormName) OR not Len(Evaluate(rqFormName)))
{
bFormErrlist = ListAppend(bFormErrlist,rqName);
}   
            
}   
}

A nice way to redirect to a page with a select option list

This ought to be in the script tag.

<!--
function nav()
{
var w = document.myform.mylist.selectedIndex;
var URL_add = document.myform.mylist.options[w].value;
window.location.href = URL_add;
}
//-->
And here is the form tag.
<form action="action.cfm" name="myform" id="myform">
Jump to:
<select name="mylist" onChange="nav()">
<option value="thisURL.cfm?ID=36" selected >This
<option value="thisURL.cfm?ID=66">That
<option value="thisURL.cfm?ID=65">Here
<option value="thisURL.cfm?ID=59">There
<option value="thisURL.cfm?ID=45">Nowhere
<option value="thisURL.cfm?ID=58">Other
<option value="thisURL.cfm?ID=55">Random
</select>
</form>

List to quoted SQL IN list

<cfset list = "one,two,three">
original=<cfoutput>#list#</cfoutput><br>
<cfset quotedList = "'#replace(list,",","','","all")#'">
sql in list=<cfoutput>#quotedList#</cfoutput>
Note the single quotes before and after the # characters.
Source: bennadel.com

Trim Form Fields

Easy way to trim form fields in ColdFusion

<!--- Trim all form fields --->
<cfloop list="#form.fieldnames#" index="field">
   <cfset temp = SetVariable("form.#field#", Trim(Evaluate("form.#field#")))>
</cfloop>

BlogCFC was created by Raymond Camden. This blog is running version 5.9.001. Contact Blog Owner