Skip to main content
Known Participant
October 9, 2017
Answered

counter field by javascript dropdown menu

  • October 9, 2017
  • 1 reply
  • 707 views

i work this javascript code menu :

var MyItems = new Array("1","2","3");

this.getField("Dropdown14.0").setItems(MyItems);

now i want a script help if user choose option "2" then count ++ field name BOX (1...2...3..4...5..............)

i try this but not working :

count=0

if (event.value=="2")

{

count ++;

}

This topic has been closed for replies.
Correct answer Thom Parker

So you want the number value in a text field to be incremented when the user selects "2" from the dropdown? Is this correct.

If it is then enter this Validation script into the dropdown

if(event.value == 2)

     ++this.getField("Box").value;

When you are driving events from a dropdown, then the code that performs the action should be in one of the dropdown scripts that is activated on a selection. The Validation script is a good choice.

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
December 15, 2017

So you want the number value in a text field to be incremented when the user selects "2" from the dropdown? Is this correct.

If it is then enter this Validation script into the dropdown

if(event.value == 2)

     ++this.getField("Box").value;

When you are driving events from a dropdown, then the code that performs the action should be in one of the dropdown scripts that is activated on a selection. The Validation script is a good choice.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often