I am trying to reset the focus to the barcode field after a bar code has been entered with a tab as its last character (testing this manually right now). The actionFunction is being called, but the focus is not back on the bar code field after a bar code is entered; the focus is on the field below it. Can someone help me figure this out? Thanks.
<apex:page standardController="Contact" extensions="PhoneAThonScanController" title="Phone-A-Thon Entry">
<apex:form >
<apex:pageMessages id="msgs"/>
<script language="javascript" type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
</script>
<apex:actionFunction name="resetFocus" focus="barCode" action="{!scanBarCode}" reRender="block,cons,msgs" />
<apex:pageBlock title="Inventory Item Receipt" id="block">
<apex:pageBlockButtons >
<apex:commandButton action="{!Cancel}" value="Cancel"
onclick="return confirm('Unsaved contacts will be lost. Are you sure you want to cancel?');"
immediate="true" rendered="{!contacts.size > 0}"/>
<apex:commandButton action="{!cancel}" value="Cancel" immediate="true" rendered="{!contacts.size = 0}"/>
<apex:commandButton action="{!save}" value="Save" rendered="{!contacts.size > 0}"/>
</apex:pageblockbuttons>
<apex:outputPanel id="panel" >
<apex:outputText value="Bar Code " rendered="{!readyToScan}" />
<apex:inputText value="{!barCode}" rendered="{!readyToScan}" onchange="resetFocus()" id="barCode"/>
<!-- <apex:actionSupport event="onchange" action="{!scanBarCode}" rerender="cons,msgs,block"/> -->
</apex:inputText>
</apex:outputPanel>
<br></br>
<br></br>
<apex:repeat value="{!$ObjectType.Contact.FieldSets.Contact_Scan_Fieldset}" var="field">
<apex:outputText value="{!field.label} " />
<apex:inputField value="{!newContact[field]}" >
<apex:actionSupport event="onchange" action="{!checkContact}" />
</apex:inputField>
<br></br>
</apex:repeat>
<br></br>
<br></br>
<apex:outputText value="Ready To Scan " />
<apex:inputCheckbox value="{!readyToScan}" >
<apex:actionSupport event="onchange" rerender="panel" />
</apex:inputCheckbox>
</apex:pageBlock>
<apex:outputPanel id="cons" >
<apex:pageBlock rendered="{!contacts.size > 0}">
<apex:pageBlockTable value="{!contacts}" var="con" >
<apex:facet name="header">
<apex:outputText value="Contacts Added To The Batch" />
</apex:facet>
<apex:column >
<apex:outputField value="{!con.Bar_Code__c}" />
</apex:column>
<apex:column >
<apex:outputField value="{!con.firstName}" />
</apex:column>
<apex:column >
<apex:outputField value="{!con.lastName}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>