Setting the initial focus in an HTML page
Date: | Archived |
---|---|
Product/Release: | LANSA for Web |
Abstract: | Sample SetFocus JavaScript function provided in the "LANSA for Web - A Developers View" guide needs to be customised for other Form element types |
Submitted By: | LANSA Technical Support |
The sample SetFocus JavaScript function provided in the "LANSA for Web - A Developers's View" guide does not include all the possible Form -graphical- elements types. Consequently, for those types not included (e.g. radio buttons, push buttons, etc.), the focus is not set. To set the focus for drop downs (combo boxes), push buttons and radio buttons, the SetFocus function could be enhanced as follows:
function SetFocus() { var NumElements=document.LANSA.elements.length; for (i=0; i<NumElements;i++) { if (document.LANSA.elements[i].type=="select" || document.LANSA.elements[i].type=="radio" || document.LANSA.elements[i].type=="button" || document.LANSA.elements[i].type=="checkbox" || document.LANSA.elements[i].type=="textarea" || document.LANSA.elements[i].type=="text") { if (document.LANSA.elements[i].value!=" ") document.LANSA.elements[i].select(); document.LANSA.elements[i].focus(); break; } } }