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

Hide a field label

Participant ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

Hi, is there anyway to hide a field label.

I have a dropdown, with a variety of types of numbers (Licence, Security, Health # etc.) I have an empty field beside the dropdown.

Which ever number type you choose, a label appears beside the empty field, indicating the choice you made.

So in the far right box, the text Authorization number should appear.

Untitled-2.gif

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.4K

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

LEGEND , Jun 07, 2016 Jun 07, 2016

OK. You can use a custom Validate script in the 2nd dropdown that looks like the following:

// Validate script for dropdown

(function () {

    // Get a reference to the label field

    var f = getField("LABEL1");

    // Show/hide the label based on the dropdown selection

    f.display = event.value === "Click to see options" ? display.hidden : display.visible;

})();

but replace "LABEL1" with the actual name of the field you're using for the label text.

That last line is equivalent to the following:

    if

...

Votes

Translate

Translate
LEGEND ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

It not clear to me what you want to hide and when you want it to be hidden. Can you elaborate?

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 ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

Hi, in the 2nd drop-down there are 5 choices, Authorization Number, License Number, File Number etc......  on the far right there is a text box, the user will type a number in. Above the text box I want text to appear as a label, based on the drop down choice. If the user does not make a choice, the text box will be hidden.

so basically, show hide a field label based on drop-down choice.

Thanks

.

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
LEGEND ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

OK, that's easy enough, but what dropdown item are you using to indicate that the user did not make a choice? People sometime use a single space or some text like "Please select".

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 ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

Sorry, should have said, I have a choice like in the first drop-down. 'Click to see 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
LEGEND ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

OK. You can use a custom Validate script in the 2nd dropdown that looks like the following:

// Validate script for dropdown

(function () {

    // Get a reference to the label field

    var f = getField("LABEL1");

    // Show/hide the label based on the dropdown selection

    f.display = event.value === "Click to see options" ? display.hidden : display.visible;

})();

but replace "LABEL1" with the actual name of the field you're using for the label text.

That last line is equivalent to the following:

    if (event.value === "Click to see options") {

        f.display = display.hidden;

    } else {

        f.display = display.visible;

    }

This all could be simplified to the following single statement:

getField("LABEL1").display = event.value === "Click to see options" ? display.hidden : display.visible;

It's best if you select the "Commit selected value immediately" option for the dropdown. For the label field, make it read-only and set the default value to the label text.

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 ,
Jun 07, 2016 Jun 07, 2016

Copy link to clipboard

Copied

LATEST

This looks good, I will let you know. thank you.

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