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

Newbie need help with JavaScript

Community Beginner ,
Sep 19, 2017 Sep 19, 2017

Copy link to clipboard

Copied

Hello everyone,

im new to using JavaScript and could really need some help. I´ve created a form in Adobe pro and what i want is the following:

If field "Comment1" contains any text user is enforced to pick a choice from drop down menu "R1" and "L1". Is it best to use validation script for this? Or calculation script?

I got over 100 rows that i want the same function in, they are named: Comment1, R1, L1; Comment2, R2, L2; Comment3, R3, L3; And so on..

I hope this post makes some sense,

Thanks in advance, Adrian

TOPICS
Acrobat SDK and JavaScript , Windows

Views

325

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 , Sep 20, 2017 Sep 20, 2017

OK, then I misunderstood before. Enter this code as a doc-level script:

function setDropdownsAsRequired() {

    var fieldNumber = event.target.name.replace("Comment", "");

    this.getField("R"+fieldNumber).required = (event.value!="");

    this.getField("L"+fieldNumber).required = (event.value!="");

}

Then you just need to call it from the custom validation script of your Comment fields, like this:

setDropdownsAsRequired();

Votes

Translate

Translate
Community Expert ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

"Enforce" how, exactly? You can set them as required, but only gets validated when the form is submitted (unless a script is used to validate it during other events). Is that what you mean?

Also, what are the actual field names of the drop-downs? Not just their options...

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 Beginner ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

Thanks for your reply!

Yes, setting them as required is exactly what i mean. The field names of the dropdowns are as i wrote: R1, L1 for the first row and then R2, L2 for second row and so on. 

Thanks in advance, Adrian

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 ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

So there are two drop-downs for each comment field?

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 Beginner ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

Yes, that is correct

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 ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

OK, then I misunderstood before. Enter this code as a doc-level script:

function setDropdownsAsRequired() {

    var fieldNumber = event.target.name.replace("Comment", "");

    this.getField("R"+fieldNumber).required = (event.value!="");

    this.getField("L"+fieldNumber).required = (event.value!="");

}

Then you just need to call it from the custom validation script of your Comment fields, like this:

setDropdownsAsRequired();

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 Beginner ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

LATEST

It worked and was exactly what i was after!

Thanks alot, you saved my day!

Regards, Adrian

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