• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Reset a dropdown menu to default in PDF form

Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

I have a drop down field in a PDF form.  When a user selects from the drop down, a popup window appears asking additional questions and those answers are inputted into another field.  If they click cancel another window pops up asking if they're sure to cancel.  If they click the YES button, I want the drop down field to revert back to the default selection.

I'm running two functions.  One is in the drop down's custom validation window called (fSystemRequest) and the other is called (fExitPortalSelect) that is running inside the (fSystemRequest) function.  So if they select YES or try to "X" out of the window, the (fExitPortalSelect) function is ran.  Here's the (fExitPortalFunction) code I have:

function fExitPortalSelect() {

    var vQuitPortalSelect = app.alert("Are you sure you want to quit?\n\nYou will not be able to gain access to the network until you answer these questions.\n\nClick 'Yes' to quit or 'No' to continue filling in the information required.",2,2);

    if(vQuitPortalSelect == "4") {

        this.getField("13: Justification").value = "";

        this.getField("System Name").reset = "Select from the dropdown menu";

        response.end;

    }

}

The line that's bold is the one I'm working on.  I've tried several different ways.  Please help...

TOPICS
Acrobat SDK and JavaScript , Windows

Views

4.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 05, 2018 Jan 05, 2018

Again, there's no such thing as a reset method. Do you want to revert this field to its default value?

If so, use this code:

this.resetForm(["System Name"]);

Votes

Translate

Translate
Community Expert ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

You can't just invent commands and hope they will work... If you want to reset a field to its default value you can either use the resetForm method of the Document object (specifying that field's name as the input parameter) or apply the field's defaultValue property to its value property.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

Morning Gilad,

I added a function:

fResetDropDown() {

   this.getField("System Name").reset();

}

And called that function inside the other function that I mentioned above.  It completes this.getField("13: Justification").value = ""; when I click the YES button but the fResetDropDown still doesn't work.  Did I input the line correctly?  I wasn't sure what you meant by "specifying that field's name as the input parameter".  Do you mean when I put in "this.getField("System Name")"?

The dropdown menu is set up where the text "Select from the dropdown menu" is the default text when the form is initially opened.  When other text is selected but the user decides to cancel when asked in the popup window, the dropdown menu stays with the text they selected and does not "default" to "Select from the dropdown menu".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

Again, there's no such thing as a reset method. Do you want to revert this field to its default value?

If so, use this code:

this.resetForm(["System Name"]);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

LATEST

Or you could use this code to reset only the field

this.getField("System Name").value = this.getField("System Name").defaultValue;

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines