These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Feel totally and completely defeated. REALLY need help.

bee tee
Registered: Mar 2 2009
Posts: 5
Answered

As a disclaimer, I'd like to apologize for an issue that has inevitably been discussed time and time again. Please, honestly, please forgive me.

I'm -trying to- create a request form. The end user can request up to five documents on this form. Each of these potentially 5 documents have a text box for the document number (Doc2...5 - one being default) and a combo box for them to select the corresponding product line (Prod2...5). The people here aren't that bright (and I fit right in, apparently), so I wanted to create a field that requires them to enter the number of documents - a radio button field or combo box. Once they've selected the number of documents they'll be requesting, the appropriate number of fields will be visible. (example: 3 products would change the visibility of Doc2, Prod2 & Doc3, Prod3)

So I've written this 25 buzzillion different ways over the span of a week and a half, and none of them seem to be right. I've got the extra fields set to invisible by default. I've been trying to use export values (which I think is right?) to determine the field values in order to change visibility of the fields. Given a person is filling out the form, they're going to be requesting at least 1 document, so I really don't need to address that field, or at least set any actions for it... (I don't think?)

Here is my latest attempt. (NumDoc = number of documents - i.e. the part that's driving me crazy)

}

var Nd = this.getField("NumDoc").value {

if(Nd==2);{
(this.getField("Doc2").display = display.visible;
this.getField("Doc3").display = display.hidden;
this.getField("Doc4").display = display.hidden;
this.getField("Doc5").display = display.hidden;
this.getField("Prod2").display = display.visible;
this.getField("Prod3").display = display.hidden;
this.getField("Prod4").display = display.hidden;
this.getField("Prod5").display = display.hidden;)
}
else;{

if(Nd==3);{

...etc

I know this is a really ridiculous way of doing it, but honestly, I don't know what else to do. I was originally working with radio buttons, all same name, all separate export values, and I did get the fields to display when the corresponding button was selected, but they STAYED visible - even when a different selection was made.

If any of you could find it in your heart to help a newb, my sanity and I would greatly appreciate it!

Thanks

Bianca

My Product Information:
Acrobat Pro 7.0, Windows
efos
Registered: Jan 8 2009
Posts: 63
Fields, lists, and the like are not my forte, but I can help with the basic js logic:

Let me trade you a switch statement for that If ... else tree you've got there. I can only see 20% of it and it's giving me a headache; I can't imagine what it's doing to you :)

//Let's default them invisible this.getField("Doc1").display = display.hidden;this.getField("Prod1").display = display.hidden;this.getField("Doc2").display = display.hidden;this.getField("Prod2").display = display.hidden;this.getField("Doc3").display = display.hidden;this.getField("Prod3").display = display.hidden;this.getField("Doc4").display = display.hidden;this.getField("Prod4").display = display.hidden;this.getField("Doc5").display = display.hidden;this.getField("Prod5").display = display.hidden; switch(Nd){ //Then turn on what we need case 5:this.getField("Doc5").display = display.visible;this.getField("Prod5").display = display.visible; case 4:this.getField("Doc4").display = display.visible;this.getField("Prod4").display = display.visible; case 3:this.getField("Doc3").display = display.visible;this.getField("Prod3").display = display.visible; case 2:this.getField("Doc2").display = display.visible;this.getField("Prod2").display = display.visible; case 1:this.getField("Doc1").display = display.visible;this.getField("Prod1").display = display.visible; }

I don't see where this should fail on its own; I've used display to successfully show/hide fields. As an isolated method it looks ok. If I had to guess what was causing a problem all I've got left is the Nd variable. Is it coming in as a string? To make sure that you're getting a number and not a string from that field:

var Nd = parseInt(this.getField("NumDoc").value )
Not sure if parseInt() is necessary, but it will eliminate my first suspicion that Nd may be NaNing up your efforts.

(Edit: In my test parseInt() was not necessary, switch (getField("NumDoc").value) worked as intended)

(Edit 2: parseInt() would also help if you've got non-numbers in the NumDoc field. Letters, spaces, etc.)
bee tee
Registered: Mar 2 2009
Posts: 5
Thanks so much for responding so quickly! I actually just got home from work, so I won't be able to test it right now. However I'm not sure... I mean, I did try a switch statement at one point... Maybe I put it in the wrong place? But the other thing I'm wondering is if that statement would only show the fields that each case is calling? If the user were requesting 5 documents, I'd need all 4 additional fields to be visible. I do have the text & combo box defaults set to invisible - not in code, but in the Properties menu -- which is part of the confusion for me... When I had the NumDoc field set up as radio buttons, selecting one of the values would change the visibility properties (based on export values) to "visible," which would then screw up everything. When the NumDoc selection was changed, they'd still be visible when they weren't meant to be. If the selection were changed at some point after it had been committed once, would I have to write an event script that resets the field and applies the new export value?I'll try to recreate the same thing here at home... I'll post the results once I've tried it.

Sorry for the follow-up 20 questions :-S ... but thanks so much again for your help so far!
efos
Registered: Jan 8 2009
Posts: 63
bee tee wrote:
But the other thing I'm wondering is if that statement would only show the fields that each case is calling?
No, since there is no break statement, each case will execute the cases that follow it. So "3" will execute 3, 2, and 1.

Quote:
When the NumDoc selection was changed, they'd still be visible when they weren't meant to be.
To prevent this I would wrap everything I wrote above in the function you call to evaluate visibility. That way you force everything off.

Hopefully someone else can help you with the radio buttons, I've never used them. I did notice that when reading the value of a text field, unless I hit enter when I changed the text, the value property wouldn't update even though it displayed a different number. Maybe your radio button problem is related.