Is there a way to change the key assigned to going to the next field for the "enter" key rather than the default "tab" key in a limited area within the form?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Here is an example: https://acrobat.com/#d=RZ1lzX23*u7L4N9rtWCYPQ
Note if the user uses the tab key then the script will not fire.
Good luck,
Niall
PS One thing to bear in mind is that "index" is zero based, whereas "count" starts at 1.
Views
Replies
Total Likes
You will need to enter this script in the exit section as JavaScript into each field:
if (xfa.event.commitKey == 2){
xfa.host.setFocus("fieldname");
}
The fieldname is the field you want to go to next.
Also, to be consistent, make sure your tabbing order is in line with the scripts.
Views
Replies
Total Likes
Unfortunately, it turns out to be a bit more complex as the next field is a cell within a row in a dynamic table.
I have worked this out based on your excellent advice:
if (xfa.event.commitKey == 2){
xfa.host.setFocus("EditorialCreditForm.ProductInfo.Table3.Row[3].FirstChoice");
}
then the next field has this:
if (xfa.event.commitKey == 2){
xfa.host.setFocus("EditorialCreditForm.ProductInfo.Table3.Row[4].FirstChoice");
}
etcetera...
Now, it works perfectly well, thank you, however, when I add another row to the table with the addRow button, the code does not translate properly.
This suprised me as similar codes have worked in the past.
The increment on the row number doesn't seem to work at the last row of the table.
Any thoughts...
Views
Replies
Total Likes
Ahhh...that's a good question. The only thing I can think of is to count the rows/instances and write some IF statements. Hopefully the real pros can help...
Views
Replies
Total Likes
Hi,
Westlakejager's script will do the job, I think you just need to be a bit more dynamic in the row instance.
If I understand you correctly you want the focus to go to the same object, but on the next row down. If so then something like this should work:
if (xfa.event.commitKey == 2)
{
var nextRow = this.parent.index + 1;
var nextHit = xfa.resolveNode("EditorialCreditForm.ProductInfo.Table3.Row[" + nextRow + "].FirstChoice");
xfa.host.setFocus(nextHit);
}
If you wanted the enter to set focus an object on the same row it would be easier, as Acrobat would assume you want the object in the same instance:
if (xfa.event.commitKey == 2)
{
xfa.host.setFocus("thirdChoice");
}
Hope that helps,
Niall
PS If this works in any way, you may need to test first that the user is not already on the last instance, otherwise it will be out of bounds. Maybe if it is on the last instance, set focus to the top of the table or somewhere else.
Views
Replies
Total Likes
I tried and that works well, although, once you're on the last row, how would you get to the next field?
Views
Replies
Total Likes
Hi,
Here is an example: https://acrobat.com/#d=RZ1lzX23*u7L4N9rtWCYPQ
Note if the user uses the tab key then the script will not fire.
Good luck,
Niall
PS One thing to bear in mind is that "index" is zero based, whereas "count" starts at 1.
Views
Replies
Total Likes
Well done Sir!
Views
Likes
Replies
Views
Likes
Replies