Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Acrobat X: display/hide fields via Javascript

    I need help with a script that I cobbled together from an example script; I'm not good enough at java to edit it for my needs.

    I have a form where I would like different drop down fields would be visible/hidden depending on the choices made from other drop down menus.

    If (for example) they select paper type "white" or "color" then "white" will result in a second menu of paper choices, the "color" selection result in them picking the paper wieght, then from there the color.

    My problem stems from the fact that my form is very linited in space, so I would like some of these fields to be essentially on top of each other; visibility dependant on previous choices. I can get to Menu 1 (select paper color) and then Menu 2 if they select white. But there's a problem with setting up a third menu in this series, if they select "color" from Menu 1, then I try to have a drop down for paper weight, all the fields except for Menu 1 are hidden. Playing with the script let me have them all visible, but again, I'm limited on space and can't really spread them out.


    I know I'm missing one small command... somewhere.

    Here is the script I'm working with:


    Code:
    function control_section_fields() {
    
        if (event.willCommit) return;
    
        // Get the value selected in the combo box
        var section = event.changeEx;
    
       // Hide all of the entry fields
        getField("sec").display = display.hidden;
    
        // Reset all of the entry fields
        resetForm(["sec"]);
    
        // Display the fields for the selected section
        getField("sec." + section).display = display.visible;
    
    }
    where the drop down fields are named "sec.a.dd" for example, and the Export value of different values are assigned as "a", "b", etc.

    Sorry for the rambling. Any help will be greatly appreciated.
    Last edited by fogharty; 09-11-2012 at 09:12 PM. Reason: spacing

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    maybe this is some thing with Acrobat X (which I know nothing about), but if you use display:none instead of visibility:hidden the hidden elements don't take up any space at all (but then display.hidden doesn't make much sense in javascript - I guess you will have to look at the documentation to see if you can use display.none)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •