These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Changing the value of a button's script element using JS

marcusbaake
Registered: Aug 20 2009
Posts: 6

Hi,

I'm creating an interactive document list that renders a two-column table based on the selection of a drop-down list. The column are added using the instanceManager based on the first row that is always present (independent of the selected item of the drop-down list).

The first column contains the doc name (fixed for row 1 and pulled from an array starting with row 2), the second column contains a button that has the the following JS code for its "clicked" event (also fixed for row 1):

xfa.host.gotoURL("TrainingGuides\\Basics.pdf", 1);
What I'm trying to accomplish, is changing the "clicked" script of each row's button to point to the correct URL based on the current document's title (from the "docs" array).

I managed to change the value of each button's "event.script.value" element, but in the final PDF the URLs of all buttons are still pointing to "TrainingGuides\\Basics.pdf" instead of the changed URL. What confuses me is the fact that the correct URLs are displayed in the alert messages...

This is the relevant JS code snippet from the drop-down list's "change" event:

for (i = 1; i < docs.length; i++) {
   // Add row based on first row.
   newRow = form1.mainframe.DocsTable.Row1.instanceManager.addInstance(1);
   // Change text of left table cell to name of current doc.
   newRow.LeftCell.value.resolveNode("#text").value = docs[i];
   // Change the button script of the right table cell to point to the current doc.
   newRow.Button1.resolveNode("#event[0]").script.value = "xfa.host.gotoURL('TrainingGuides\\" + docs[i] + ".pdf', 1)";
   // Just for debugging... This displays the current script value.
   app.alert(newRow.Button1.resolveNode("#event[0]").script.value); }

I guess there is something missing that kind of "refreshes" the buttons' URLs, but all my playing around with remerge(), recalculate() and relayout() just made things worse.

Can anybody help me with this?

Marcus

My Product Information:
LiveCycle Designer, Windows
marcusbaake
Registered: Aug 20 2009
Posts: 6
Solved... A friendly user on the adobe forums already helped me out.

The solution is to modify the button URL at the time the user clicks the button (i.e. in the "clicked" event) and not when populating the table:

var docName = this.parent.LeftCell.value.resolveNode("#text").value;xfa.host.gotoURL("TrainingGuides\\" + docName + ".pdf", 1);