Retain Tab Order or Set Focus on Web Refresh

I have a form users fill out on web.

I want to validate the existence of telephone number after the user enters the number. Currently, I have an iframe with embedded view that’s hidden if there is not an existing document with the same phone number. This works really well for what I need.

PROBLEM: The issue is with the focus after the doc refreshes. Since the phone number field is just text, there’s no option to “refresh on keyword change”. So I’m using the following code in my onChange:

var Phone = document.forms[0].CustomerPhoneNumber.value;

document.forms[0].CustomerPhoneNumber.value = validatePhone(Phone);

_doClick(‘$Refresh’,this,null);

This will refresh the document for me and show the iframe if necessary. The validatePhone routine is inconsequential, but I included it here so you can see all the code in onChange.

QUESTION: Can I set focus to the next field that should be in the tab order? When I refresh it will just leave focus nowhere (or in the iframe?). I’ve tried adding the following to the end of the onChange with no luck:

document.forms[0].CustomerAddress.focus;

Subject: Retain Tab Order or Set Focus on Web Refresh

I would try to do something like this:

  1. Create a text field (type=hidden)

  2. Before _doClick… in onChange add following: document.forms[0].NextField.value=“CustomerAddress”;

  3. at the end of the form (or in onLoad event) put computed text (as pass-thru HTML):

  4. Empty the NextField when you save the document. @If(@IsDocBeingSaved;“”;@ThisValue) in field’s Input Translation should work.

/Andrei

Subject: RE: Retain Tab Order or Set Focus on Web Refresh

Andrei - thanks. I believe that will do the trick for me!! I was thinking I would have to do something like that.