1 Reply Latest reply on Feb 6, 2014 7:53 PM by George_Johnson

    Make a button to hide all visible buttons, except the "hide" button

    jdutle

      I need to make a button that will hide all the visible buttons on the page, except for the one that does the hiding.  I am creating a employee office map. Each employee is listed as a bookmark, and when their name is clicked a picture button becomes visible where they sit.  If multiple names are clicked I want a way to clear all of the buttons that have been made visible. 

       

      I have been able to accomplish this by making several actions for each employee bookmark. But we have a 100 employees, so each employee would have a 100 actions. 1 action to make visible the employee picture button and then 99 actions to hide everyone else's picture buttons.

       

       

      I hope that makes sense. Thanks for any help.

        • 1. Re: Make a button to hide all visible buttons, except the "hide" button
          George_Johnson MVP & Adobe Community Professional

          It will make it much simpler to use JavaScript and hierachical naming for the buttons. For example, if you give each button a prefix of "E." (for Employee), you can hide them all with a single JavaScript statement, and then show the one that you want. So the buttons could be named "E.1", "E.2", "E.3", etc., and the code yo show the 42nd employee could be:

           

          // Hide all of the employee buttons

          getField("E").display = display.hidden;

           

          // Show employee 29

          getField("E.29").display = display.visible;

           

           

          You can make this into a function that you place into a document-level script, something like:

           

          // Hide all employee buttons and show the one specified

          function showEmployee(employee_num) {

           

              // Hide all of the employee buttons

              getField("E").display = display.hidden;

           

              // Show the specified employee button

              getField("E." + employee_num).display = display.visible;

           

          }

           

           

          and you'd then call this in the bookmark JavaScript action like:

           

          // Show #29

          showEmployee(29);

           

           

          So each bookmark action is reduced to a single line of code.