Set Focus on 1st input field in a form

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Set Focus on 1st input field in a form

Post by BLOMASKY »

Again, with oodles (is that a word?) of help from support, If you put the following in a forms Initialization script, the cursor will start on the 1st field.

AwareApp_FormParser.prototype.setFocus=function(sectionName) {
if (this.m_fields ) {
var firstTabIdx = null, focusSet = false;
for (var i = 0, len = this.m_fields.length; i < len; ++ i) {
var f = this.m_fields ;
var tabIndex = f.getTabIndex ();
if (tabIndex && tabIndex == "1") {
firstTabIdx = f;
if ((! sectionName || sectionName == f.getSectionName ()) && f.setFocus ())
focusSet = true;
break;
}
}
if (! focusSet) {
for (var i = 0, len = this.m_fields.length; i < len; ++ i) {
var f = this.m_fields ;
if (f != firstTabIdx && (! sectionName || sectionName == f.getSectionName ()) && f.setFocus ())
break;
}
}
}
}
Post Reply