1 Reply Latest reply on Jul 5, 2010 5:39 AM by pguerett

    Dynamic row setFocus...

    ChiTriGuy67

      Hi Gang -

       

      I have been lurking around here for a few weeks and I have been tasked to develop some forms for my organization so, yes, I'm a newbie.

       

      That being said if someone could help me keep the rest of my hair I would greatly appreciate it.

       

      I have a dynamic form containing a table with Row2 that I intend to grow.  The row contains the following fields:

      QTY, DESC, PRICE, PER, and TOTAL

       

      I have it set that when the user exits the PER field the following Javascript happens:

       

      Table1.Row2.instanceManager.addInstance(1);

      xfa.host.setFocus("Table.Table1.Row2.QTY2[+1]");

       

      The intent is that it will take the user to the next row's (instances) QTY field so they can continue entering information but invariably the form takes the user to the next tab order stop.  I have even tried manually specifying the cell to test it out, i.e.  xfa.host.setFocus("Table.Table1.Row2.QTY2[1]"); and this isn't working either.

       

      I'm sure this is something easy but any assistance would be greatly appreciated...thanks!

        • 1. Re: Dynamic row setFocus...
          pguerett Level 6

          Its not as easy as you think .....when you add a subform instance the objects that are created do not get registered (i.e. Acrobat knows about them until the script is ended). So when you try and set focus in the same script that object does not exist yet. So you have two choices.

           

          1. Run the addInstance script from a function - so that it does get registered when the function completes. (I have not tried this but logically it shoudl work)

          2. There is an Acroform command that will allow you to execute a command in the future. You could configure it to run the setFocus command in the future (1 sec later) and your script will be complete and the fields registered.

           

          Here is the syntax for the command:

           

           

           

          var setField = app.setTimeOut("this.getField('form1[0].#subform[0].TextField1[0]').setFocus();", 1);

           

          In this context the "this" refers to the document object in Acrobat and you have to use the Acroform field structure to get the field name. Lastly the 1 at the end is how long you want to wait before executing the command (it is in millisecends I believe). You can get more information about this command from the Acrobat Javascript reference.

           

          Hope that helps

           

          paul