Skip navigation
rodneyfleming
Currently Being Moderated

Hidden fields in Adobe using Java

Aug 16, 2012 5:36 PM

Tags: #acrobat #pdf #script #javascript #scripting #acrobat_x_pro

Hello,

 

I am trying to write a script that will hide a certain field based off the value inserted in another field.

 

I have started with this:

 

   var show = true;

   if(this.getField("quantity1").value.length == 0)   show = false;

 

   if(show)   this.getField("linetotal1").value = display.visible;

   else   this.getField("linetotal1").display = display.hidden;

 

   event.value = this.getField("quantity1").value * this.getField("unitprice1").value;

 

Now, when there is no value inserted in "quantity1", then the correct field "linetotal1" is hidden.  The problem I am having is the field is staying hidden if I go back and put a value in "quantity1".

 

Is there a way to have a loop or another if statement to correct this problem? Or is there a better way to do this action all together?

 

Thanks in advance,

Rod

 
Replies
  • George Johnson
    9,208 posts
    Aug 11, 2002
    Currently Being Moderated
    Aug 16, 2012 9:05 PM   in reply to rodneyfleming

    Simplifying a bit, try this:

     

    // Show/hide linetotal1

    getField("linetotal1").display = getField("quantity1").valueAsString ? display.visible : display.hidden;

     

    // Calculate this field's value

    event.value = getField("quantity1").value * getField("unitprice1").value;

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points