-
1. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 10:00 AM (in response to lmphil)Where did you place this code and what is the exact text of the error you're getting? Is it line 6 or line 7 (you mentioned both)?
You should not be using the hidden property and should be using the display property. The former has been deprecated since the latter has been available.
-
2. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 8, 2014 11:14 AM (in response to George_Johnson)Thanks for your response, George.
I placed this code in the actions of the "WorkerMailingAddressChoice" check box. The error basically is just as stated; I assumed the error was with Line 6 (so the script would not continue to 7).
What can you tell me about the Display property? Is this new? I am using Adobe Acrobat X.
Thanks for all of your helps.
-
3. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 11:29 AM (in response to lmphil)OK, so the Mouse Up event of the check box. You didn't provide any error message, so I don't know what you mean by "the error is basically as stated". But it looks like the problem is you're not using the right quote marks around "Yes". Do not use any curly quotes (aka smart quotes, typographer's quotes).
Regarding the display property, it has been around since Acrobat 4. More information is in the Acrobat JavaScript reference that's included in the free Acrobat SDK.
-
4. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 11:33 AM (in response to George_Johnson)As an example, this line:
WorkerMailingAddressFld.hidden = false
should be changed to:
WorkerMailingAddressFld.display = display.visible;
and to hide:
WorkerMailingAddressFld.display = display.hidden;
-
5. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 8, 2014 11:56 AM (in response to George_Johnson)Thanks again for your help. I got the script to work in the fact that if I click on the "WorkerMailingAddressChoice" check box, the desired fields are hidden. The problem is that if I uncheck the "WorkerMailingAddressChoice" check box, the fields remain hidden. What am I doing wrong? Thanks for your help.
-
6. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 12:24 PM (in response to lmphil)You'll need to post your revised script. Also, check the JavaScript console for any errors by pressing Ctrl+J.
-
7. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 8, 2014 12:28 PM (in response to George_Johnson)I decided to try just one field at a time and add the others once I get this one working.
Here is the script:
var WorkerMailingAddressFld = this.getField("WorkerMailingAddress")
if (event.target.value == "Yes") {
WorkerMailingAddressFld.display = display.visible
}else {
WorkerMailingAddressFld.display = display.hidden
}Thanks for your help.
-
8. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 12:31 PM (in response to lmphil)What happens if you use this instead:
var WorkerMailingAddressFld = this.getField("WorkerMailingAddress");
if (event.target.value !== "Off") {
WorkerMailingAddressFld.display = display.visible;
} else {
WorkerMailingAddressFld.display = display.hidden;
} -
9. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 8, 2014 12:48 PM (in response to George_Johnson)THAT'S IT!!!!! Works perfectly!!! THANK YOU! THANK YOU! THANK YOU!
-
10. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 1:01 PM (in response to lmphil)The problem then is probably that the export value of the check box is not set to "Yes", as the previous script expected. Since an unchecked check box or radio button will always have a value of "Off" (but not "OFF", "off", or anything else), this is a safer way to check the state of the field. There is also the isBoxChecked field method that you can use, but I never liked it.
-
11. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 8, 2014 1:09 PM (in response to George_Johnson)Thanks again! Your help is much appreciated.
Just curious. This situation dealt with a check box. What if the situation were a blank field. As long as that field was empty, the desired field boxes would remain hidden. Any advice?
-
12. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 8, 2014 1:28 PM (in response to lmphil)In that case you'd use a script in the Validate event of the text field, and the if statement would be changed to:
if (event.value) {
Which in English means: "If this field has a value (i.e., is not blank)..."
-
13. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 9, 2014 9:02 AM (in response to George_Johnson)Thank you very much for all of your help! It is truly appreciated! Creating a script for a field that allows text, I tried "if (event.value) {", as you suggested. When I tab to the field, the hidden fields display before I enter anything and I can't hide again. Any suggestions?
Thanks again for your help.
-
14. Re: Help Debugging a JavaScript in Adobe Acrobat
George_Johnson Jul 9, 2014 10:39 AM (in response to lmphil)Where exactly did you place the code, and can you show the entire script? It is supposed to be a Validate script, but it sounds like you place it somewhere else.
-
15. Re: Help Debugging a JavaScript in Adobe Acrobat
lmphil Jul 9, 2014 11:19 AM (in response to George_Johnson)Thanks for your help. Here's the situation. I created a form with text fields, number (currency) fields, and calculated fields. The calculated fields display the currency symbol (even when there is nothing to calculate and this causes a problem for our users who just want to print out the form and fill it out by hand (The currency symbols get in the way.). So, I wanted to write a script the would make the calculated fields hidden unless there was actually something entered in the first text field (EmpID). Based on our earlier discussions, this is what I came up with (TotalCompensationRow1 is a calculated field.):
var TotalCompensationRow1Fld = this.getField("TotalCompensationRow1")
if (event.value) {
TotalCompensationRow1Fld. display = display.visible
}else {
TotalCompensationRow1Fld. display = display.hidden
}Somehow, I think I'm making this much more difficult than it needs to be. Thanks again for your help.


