Links

Home
Open Source
The News Blogs
About W3 Systems
References
C++ Reference
SEO
MySQL
CSS
Meta-Site
C++ Tutorial
Quirks Mode
Bug Collection
Detecting The World
Free CSharp
Javascript Reference
Meta-Site
ASCII Table
Network Engineering
HTML DOM
HTML5
SSL
Primes
Spellchecking
PDF Conversion
Sabbaticals
Amazon EC2
XML
Java References
Health Sharing
Sleep
Wall Builders
Selective Immune suppression
Talking it over

DHTML DOM References


Setting Focus.

The following function is a lifesaver.
It's an automatic usability enhancement for forms.
 It insures that focus is set on the first valid control.
Just call it from the onload event. 
function focusFirstControl( formID )
{
var frm = document.forms[formID];
if( frm )
{
// iterate throuugh form controls, find the first usable one to focus.
for(i in frm.elements)
{
if( frm.elements[i] && frm.elements[i].tagName )
{
var tagName = frm.elements[i].tagName;
if( tagName == "SELECT" || tagName == "INPUT" && frm.elements[i].type == "text" || tagName == "TEXTAREA" )
{
if( tagName == "INPUT" && frm.elements[i].readOnly )// check readonly property
continue;
if( frm.elements[i].disabled ) // is it disabled
continue;
if( frm.elements[i].offsetWidth == 0 ) // best visibility indicator I could find
continue;
frm.elements[i].focus();
break;
}
}
}
}
}  
 
 
 

http://www.mozilla.org/docs/dom/domref/dom_shortTOC.html
Copyright (C) 2009 - W3 Systems Design