example JavaScript to show/hide layer of BCG in Acrobat DC

I saw this question a couple of times but not enough answers, so I'll ask a little more precisely.

I have a listbox with three different option (option 1 is 'Blue', is a 'Green' option 2 and option 3 is "Yellow")

There are 3 matching layers named BlueLayer, GreenLayer and YellowLayer.

When 'Blue' is selected in the drop-down list, I would like BlueLayer to show (but not GreenLayer or YellowLayer).

When 'Green' is selected in the drop-down list, I wish GreenLayer show (but not BlueLayer or YellowLayer).

When 'Yellow' is selected in the drop-down list, I want to show YellowLayer (but not BlueLayer or GreenLayer).

My theory is that if I select the box that says commit selected value immediately, I should be able to run a javascript script on the MouseUp command allowing the correct corresponding layer to show.

Could someone show me an example of what this javascript would look like or suggest a better way to do it?

I know that Radio buttons are another option, but in the end, I prefer a list because of the design of the form box.

BTW, I'm new to using javascript in Adobe Acrobat so if I'm completely off base with my way of thinking, please point me in the right direction.  Thank you in advance!

First, you must use the Validate or Format, not MouseUp events. I prefer to use the old.

Here's how I'd do:

var layers = this.getOCGs(0); // let's say the layers are only on the first page of the file.
for (var i in layers) {
    if (layers[i].name=="BlueLayer")
        layers[i].state = (event.value=="Blue");
    else if (layers[i].name=="YellowLayer")
        layers[i].state = (event.value=="Yellow");
    else if (layers[i].name=="GreenLayer")
        layers[i].state = (event.value=="Green");
}

If the layers appear on multiple pages, and then you add another loop around the code, to go through all the pages, but the basic concept is the same.

Tags: Acrobat

Similar Questions

  • Can we capture the event of show/hide layer in PS?

    Hi all..!!!

    I have a request to all the coders of Photoshop! We can capture the click event of show/hide layers in Photoshop... ? I need to know my code if the user clicked on the eye of show/hide layer... !!

    Pls answer soon... !!

    Thank you!

    http://forums.Adobe.com/thread/858391?TSTART=0

  • Captivate: Using Javascript to show/hide captions text

    Hello

    I want to show/hide a legend of text using javascript. I can't find the way to do it with advanced actions. I don't know if it's because it belongs to a question slide in a pool. Anyone know if this is possible and how this can be done?

    There is nothing wrong with your English - no need to apologize :-)

    I just tested it. Seems to work for me to create a tip action that will show my custom legend if I set a variable of personalized tour. Rather than xplain, I have attached a word with some screen shots doc and an example of file CPTX. File is Captivate 5, but even should work in 5.5

    Steve

  • Anyone know the JavaScript to show/hide content based on the country field?

    Hi, I need to display a different number on a site according to the area of the country (com.au or co.nz). I figured out that the module {module_urlcountrycode} can be used to do this with javascript.

    Because I'm not exactly an ACE to js, is there anyone who could share the code?

    See you soon

    Jerun

    Place the module as a class-{module_urcountrycode} country, then you can simply the elements to give their own class and then you see depend on.

    . Country-nz .nzelement {display: block ;}}

    And by default all elements of the country have a class contryelement or something and all hidden by default.

  • Show/hide layers in PDF format on iOS

    Hi - I ask it just to see if there is perhaps a more modern response: is theer any (links, buttons, javascript) to show/hide layers or any content on an iOS device? Thank you!

    Hi patrickh20438662,

    If you are referring to the option on the iOS device, then I am sorry that there is no available option to show or hide layers on iOS device.

    Kind regards

    Meenakshi

  • Show/hide guides through JavaScript?

    Show/hide guides through JavaScript?

    With this script, I can delete all bookmarks in all open documents:

    for (d = 0; d < app.documents.length; d ++) {}

    var targetDocument = app.documents [d];

    activeDocument = targetDocument;

    var doc = app.activeDocument;

    for (var i = doc.pathItems.length - 1; i > = 0; i--) {}

    var p = doc.pathItems [i];

    If (p.guides == true) {}

    p.Remove ();

    }

    }

    }

    But, how can I modify this script to show/hide guides?

    Thank you.

    victorcarbajo wrote:

    "p.hidden =! p.hidden; "or"p.hidden = true"deletes (?) guides.

    I just tested it with the code you have posted, it works fine for me. Did you remove the line: p.remove () and replace it with the one I posted above? p.hidden =! p.hidden;

    In regards to the executeMenuCommand I guess whenever his name, he would have switch between the current state, but do not know, I do not have CS6 + to test.

  • Show/hide Sub forms in LiveCycle ES 8.2

    Hi all

    I use Livecycle to create a form and want to following features:

    If a specific value is selected in the drop-down list, it should show/hide a sub-shape.

    However, I am not able to do. I looked at adobe livecycle documents, Adobe and GOOGLE user forums but fail to run the code.

    I used suite PDF as an example:

    http://partners.Adobe.com/public/developer/en/LiveCycle/Designer/PDFs/ChangingObjectPresen Ed.pdf

    The code below is written on the drop-down box and I BMD_Form like subform

    -form1. POINT OF SALE. Emphasis_info.subformOptions::change - (JavaScript, client)-

    Switch (xfa.event.newText) {}

    case "Invisible":

    form1. POINT OF SALE. BMD_Form.presence = "invisible"; or

    break;

    'Hidden' of cases:

    form1. POINT OF SALE. BMD_Form.presence = 'hidden ';

    break;

    by default:

    form1. POINT OF SALE. BMD_Form.presence = "visible";

    break;

    }

    Thank you

    Viral

    The code works properly, please check how the pdf was saved? static/dynamic? Make sure that he recorded in dynamic pdf.

  • LiveCycle Form - box needs to show/hide images

    My box is called Ucheck.  The image is named UStamp.  I need the box to activate the visible image.

    I have read other responses to forum and found this example:

    showHide = event.target.isBoxChecked var (0)? display.visible:display.hidden;


    this.getField("Text036").display = showHide;

    However, when I have the script above in my form (changinging the (getField to "Ustamp") on LiveCycle, it gives me this answer)

    Script failed (language formcalc; context is)

    xfa form [0] [0]. U check [0]. #subform [0]. Ucheck [0]

    script = var showHide =

    event.target.isBoxChecked [0]? display.visible:display.hidden;

    this.getField("Ustamp").display = show - hide

    : Error syntax near token '? "on line 1, column 44.

    When I take the '? ', he said: he doesn't like something else on the script.

    I don't know ANYTHING about Javascript, so do not have the slightest idea how to debug this.  I don't program in Access, but know not true either VB.

    Thank you for your help...

    Do you have, you save the form as dynamic... in the dialog box save as file make sure you that you choose a dynamic PDF as type.

    Paul

  • What is the best way to show/hide n number of columns?

    Hello

    I have a dynamic report that I have show/hide columns works using the code below. But when there is 500 or more lines, that it takes about a minute or more just waiting to see the columns that toggle.

    What is the best way to do it?

    Existing JavaScript
    [script language = "JavaScript" type = "text/javascript"]
    var mymonths.length = maxcnt;
    function hideMaxEarn() {}
    for (var j = 0; j [maxcnt; j ++) {}
    hideColumn('MON'+mymonths[j],'MAXCOL'+mymonths[j]);
    hideColumn('MON'+mymonths[j],'EARNCOL'+mymonths[j]);
    }
    hideColumn ('MON13', 'MAXCOL13');
    hideColumn ('MON13', 'EARNCOL13');
    }
    function showMaxEarn() {}
    for (var j = 0; j [maxcnt; j ++) {}
    showColumn('MON'+mymonths[j],'MAXCOL'+mymonths[j]);
    showColumn('MON'+mymonths[j],'EARNCOL'+mymonths[j]);
    }
    showColumn ('MON13', 'MAXCOL13');
    showColumn ('MON13', 'EARNCOL13');
    }
    function getCellIndex (pRow, pCell) {}
    for (var i = 0, n = pRow.cells.length; i [n; i ++) {}
    If (pRow.cells [i] == pCell) return i;
    }
    }
    function hideColumn (pMon, pCol) {}
    var l_Cell = $x (pCol);
    var l_Table = html_CascadeUpTill (l_Cell, 'TABLE');
    var l_Rows = l_Table.rows;
    l_CellI = getCellIndex (l_Cell.parentNode, l_Cell);
    for (var i = 0, n = l_Rows.length; i [n; i ++) {}
    If (I! = 0) {}
    html_HideElement (l_Rows [i]. Cells [l_CellI]);
    } else {}
    $x (pMon) .colSpan $x (pMon) .colSpan = - 1;
    }
    }
    }
    function showColumn (pMon, pCol) {}
    var l_Cell = $x (pCol);
    var l_Table = html_CascadeUpTill (l_Cell, 'TABLE');
    var l_Rows = l_Table.rows;
    l_CellI = getCellIndex (l_Cell.parentNode, l_Cell);

    for (var i = 0, n = l_Rows.length; i [n; i ++) {}
    If (I! = 0) {}
    html_ShowElement (l_Rows [i]. Cells [l_CellI]);
    } else {}
    $x (pMon) .colSpan = 3;
    }
    }
    }
    return;
    }
    [script]

    Hi Bill,

    Can you just check to see if the report actually adds the ID attribute for each TD. In a normal report, if you include the ENAME field, for example, all TD in this column have an ID = "ENAME". If this is the case, you can use document.getElementByID ("ENAME") to retrieve a collection of these - this would be faster browse this collection through the rows/cells.

    In addition, if possible, you should only perform research and calculations once. You have mymonths [j] several times in loops - create a variable to hold this for each iteration of the loop and refer to the variable. You also n = l_Rows.length in loop definition - put this above the loop that you only need to calculate this time.

    You can also find more efficient to perform ObjectName. style.display = 'none' * instead of the html_HideElement() method as it is easier.

    If FF3 was a bug in which does not hide the NECK tag columns, I suggest using those rather--it would mean the creation of a new report template, but it would have been the quickest method as you can style an entire column to style her NECK tag (drawback, it's that the NECK tag cannot be created dynamically so it should appear in the report model).

    Andy

    Published by: ATD 26 Sep, 2008 15:03

  • Show/hide fields based on T/F control - only showing or hiding, not both.

    Hi Forum,

    I'm looking to show/hide fields address based on a T/F control (or a single entry check box).

    My online form has a number of business address fields, a T/F control and a number of postal address fields. I want the mailing address fields to hidden when a user clicks on the box 'As Above' (and demonstrated once again if they click this box once more).

    I used the sample code (https://docs.oracle.com/cloud/latest/process_gs/CPRCW/GUID-F3BD3386-F333-45C6-AA56-C77136D169E5.htm) as a starting point for my Web form rule and it works as expected the first time that a user clicks area T/F (i.e. He's hiding the post fields) but it does not work the second time they until it clicks (where I assumed that fields would still be visible).

    The T/F box has the following options:

    true = as above

    false = No

    And my web rule looks like this:

    If (AsAbove.value = true) {}

    PostalAddress.visible = true;

    PostalState.visible = true;

    PostalPostCode.visible = true;

    } else {}

    PostalAddress.visible = false;

    PostalState.visible = false;

    PostalPostCode.visible = false;

    }


    I tried the same thing (with similar results) using a Checkbox control with a single option (according to the example code)

    If (PostalAddressCheckbox [0] .value == 'As Above') {}

    PostalAddress.visible = true;

    PostalState.visible = true;

    PostalPostCode.visible = true;

    } else {}

    PostalAddress.visible = false;

    PostalState.visible = false;

    PostalPostCode.visible = false;

    }

    As verified does not seem to be supported, is there another way to accomplish what I'm after, or I missed something somewhere simple (and y at - it documentation on the T/F control)?

    See you soon,.

    James.

    Hello

    Web Forms address these true-false as the boxes and, as such, in the form of tables.

    You can see if you try to print the TrueFalse value. You should get something like java object lang @XXXXXX

    Try to put the code as follows (in bold and underlined):

    If (AsAbove[0].value = true """""") {}

    PostalAddress.visible = true;

    PostalState.visible = true;

    PostalPostCode.visible = true;

    } else {}

    PostalAddress.visible = false;

    PostalState.visible = false;

    PostalPostCode.visible = false;

    }

    This should do the trick

    See you soon

    José

  • Has anyone seen this error of conditional text: show/hide is incompatible?

    When I generate my book file, I get the following error in the log:

    Show/hide hidden is incompatible.

    Does anyone have any suggestions on how to troubleshoot and resolve this problem?

    Thank you

    Janie Gulley

    FrameMaker assumes that when you export a book, you would like conditional text to shown the same way across all documents in the book. It warns you if it is not so.

    "Show/hide hidden is incompatible" means that the hidden state is not configured the same throughout your book. For example, it can be displayed in some documents but hidden in others, or an indicator of Condition red in some texts, but blue in others.

    To resolve this problem:

    1. Select a document in your book where the conditional text settings are correct and open.
    2. Click on the book and type Ctrl + A to select all the documents in it.
    3. Choose file > import > Formats. Import the Formats dialog box appears:
      1. Click deselect all.
      2. Check the conditional text settings .
      3. Click import.

    All the documents in your book have now the same conditional text as your chosen document settings.

  • Measures to honor the widget show/hide in new HR 2015 presentation of screen customization


    I was happy to see the widget show/hide in the HR 2015 Azure Blue layout. I guess she calls the expansion/collapse of the content on a DHTML page. However, I did not lead to it! What is the correct procedure?

    1. Change the theme (default)] in the layout of the blue Azure.
    2. Select one of the text box divs (this is probably the question. Where should the inserted widget?)
    3. Select ' show/hide the double State' in the widgets menu.
    4. Save the project and generate output Responsive HTML5. He failed.

    One of two things happens: either help system will not - launch loading graph is an infinite loop, or the system starts with a table of contents damaged. For example, the table of contents shows only the icons/no text content.

    Thanks in advance for any help!

    So that's how see you me Rick ;-)

    The expand/collapse I created originally ended with the RH11.0.3. updated. He is always on my backlog to create an update for this. Just didn't come around it. (I know, after more than 6 months).

    The best way is to a button or two buttons of the twisties/list script method drop-down. Add the script to the master page header and you'll have the expand/collapse in your topics. (Twisties and hide |) WvanWeelden.eu) I have the expand/collapse for the layout on the order book.

  • Show/hide field on all pages problem

    I try to use a script to show/hide document level menu (via a drop-down list) field on a 6 page document.

    If my domain is named "P1.field" on page 1, P2.field on page 2... How can etc, I do for States to field by doing the same?

    Right now my state of field changes on page 1 only.

    Just do it to all fields... Either in a loop or one by one. You can use something like this, for example:

    for (var i = 1; i)<=6;>

    this.getField("P"+i+".field").display = display.hidden;

  • develop/tab Show / Hide regions

    Try to do a dynamic button that could expand all show and hide regions on the page once click. and tabs them when you click New.

    I was wondering if anyone knows how to do this... ?

    Published by: PandaOracle on 8 June 2012 10:49

    Just use javascript to toggle below code (all show/hide all)

    $('.t1HideandShowRegionLink').children('img').click();
    
  • can radio buttons show/hide the info in an interactive pdf?

    Hello. I have a question to which I have been faced with during some time... hoping someone can help.

    I create a document in InDesign CS6. It's basically a guide with a joint questionnaire.

    I have forward and back buttons work properly - so that they take you from one page to another.

    However, the more difficult question is I want to have interactivity with the use of radio buttons and eventually the check boxes. Thus, for example, on page 1, I have a question multiple choice where there are three choices. Clicking the wrong answer shows a block of text saying 'no it's wrong' and clicking on the appropriate radio button shows the words "Yes, correct."

    I have created three blocks of text and make it into a multi-state object.

    Three problems:

    1. option buttons seem to be the option for "the State" in the buttons and Forms dialog box
    2. even if that were the case - the State Road seems to be only swf, non-interactive pdf form - is there a way to change this?
    3. script assuming that there IS a way, everything can be put in place so that instead of using radio buttons I have use of check boxes that only give the correct answer if the correct check boxes are selected.

    I would stick to indesign to do this, however, I think that the option is perhaps more suited for this problem?

    Many thanks in advance,

    SunsV

    1 - make 3 images and convert it into boxes option...

    Text blocks 2 2-make (Yes, his right) (No, the wrong) and convert it to buttons - rename it (Righ, evil)

    3 - Click on each radio button and apply action: Show/Hide button and form and on the visibility to activate the globe eye for buttons wrong or right.

Maybe you are looking for

  • Installation of Ubuntu 12.04

    Hello. I just bought an E540 Edge and I try to install Ubuntu Studio 12.04 on it. However, I have some initial difficulty. If I try and do it within Windows, even if it is said it succeeded, I'm not offered an option of Ubuntu at the start, and there

  • Conflict message

  • Whenever I try to connect wirelessly it disconnects immediately. He then referred to a box of troubleshooting.

    I did not understand a way to solve this problem... I'm wired and connected at the moment but I have not found how to fix wireless. This is the problemI have not downloaded anything new or no recent data... but it seems that my computer sees this net

  • VMW Virtual Machine CPU Utilization - script

    Hello team, As you know the virtual machine CPU usage will check for crampons, drops drama or sustained high levels in the use of the CPU on a virtual machine. But I'm looking Foglight to trigger alert when it reaches more than 95%, I want that all a

  • UAC settings do not stick

    I work in there and a lot of our PC Windows 7 Prof SP1 32-bit are suddenly unable to have their user account control settings changed (they block to "never notify") and therefore, are not prompted for an administrator password when installing new sof