//Function to set focus to the first editable control in a document //Just call it from the onload event of the body element function set_first_control_focus(strCN) { //working variables var Fid=0; var Eid=0; var ErrTxt=''; var fControl; if (strCN && strCN.length>0) { strCN.focus(); } else { //loop through the forms in the current doc for (Fid=0; Fid < window.document.forms.length; Fid++) { //loop through the elements in the current form for (Eid=0; Eid < window.document.forms[Fid].length; Eid++) { //get the ref to the element el=window.document.forms[Fid].elements[Eid]; if ((el.type=="text" | el.type=="select-one" | el.type=="textarea")&& el.readonly!=true) { if (el.type=="text") { el.select(el.length); } el.focus(); break; } } } } }