Awesome feature in Mootools 1.3..
As you may (or may not) know, I use the
Mootools framework in
CFCDoc. And in a whole lot of other things as a matter of fact.
Upon browsing through Mootools wiki, I came across an interesting feature planned for version 1.3. Check out that last one. (click image to zoom)


5578 viewed | 1 opinion(s) | del.icio.us | Digg it | Jax @ 10:05 cet
initCap for JavaScript
Just posting this to have it in my code snippets :-) Javascript function to capitalize the first letter of a phrase or word....
<script type="text/javascript">
function initCap(str) {
/* First letter as uppercase, rest lower */
var str = str.substring(0,1).toUpperCase() + str.substring(1,str.length).toLowerCase();
return str;
}
</script>
<input type="text" value="chANGE this PHrase!" name="field1">
<input type="button" onclick="alert(initCap(field1.value))" value="Test initCap">
5083 viewed | 3 opinion(s) | del.icio.us | Digg it | Tjarko @ 11:31 cet
Trim javascript function
function trim(str) {
str = str.replace( /^\s+/g, "" ); // strip leading
str = str.replace( /\s+$/g, "" ); // strip trailing
return str;
}
UPDATE: This is a Javascript function that I use to strip values. In ColdFusion you can use the standard trim() function.
<cfset var = trim(variables.x)>
or ltrim (left) / rtrim (right) functions
9367 viewed | 3 opinion(s) | del.icio.us | Digg it | Tjarko @ 10:05 cet
Setting the focus on the first form element available
<script language="javascript" type="text/javascript">
function setFocus(aForm){
if( aForm.elements[0]!=null) {
var i;
var max = aForm.length;
for( i = 0; i < max; i++ ) {
if( aForm.elements[ i ].type != "hidden"
&& !aForm.elements[ i ].disabled
&& !aForm.elements[ i ].readOnly ) {
aForm.elements[ i ].focus();
break;
}
}
}
}
</script>
<body onLoad="setFocus(document.forms[0])"></body>
4777 viewed | Your opinion... | del.icio.us | Digg it | Tjarko @ 9:45 cet