I need an Acrobat JavaScript to manage a combo box, check box and text field.

Hello Experts,

Excuse my question title; I couldn't find a better way to describe what I need.

I have a PDF document with a Combo Box, a Check box and a text field.   On the Combo Box I have the following:

$250,000/$250,000
$500,000/$500,000
$250,000/$500,000
$1,000,000/$1,000,000
$1,000,000/$2,000,000
$2,000,000/$2,000,000
$2,000,000/$3,000,000
$3,000,000/$4,000,000
$4,000,000/$4,000,000
$5,000,000/$5,000,000

If a user select any of the amounts from the combo box and do not check the check box, the text field will be empty.

If $250,000/$250,000 is selected and the check box is checked, the text field has to show "N/A"
If $500,000/$500,000 is selected and the check box is checked, the text field has to show "$500,000"
If $250,000/$500,000 is selected and the check box is checked, the text field has to show "$500,000"
If $1,000,000/$1,000,000 is selected and the check box is checked, the text field has to show "$1,000,000"

The text field has to show $1,000,000 for all the other amounts where there are selected from the combo box and the check box is checked.

Need help ASAP.  Thanks in advance for your help.





sample.pdf
cartereverettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karl Heinz KremerCommented:
How much do you know about JavaScript?
0
cartereverettAuthor Commented:
Almost nothing.  I took some VB .net classes and have the logic, but that's about it.
0
Karl Heinz KremerCommented:
That's not a problem, I just needed to know how much detail I have to provide to setup e.g. a document level JavaScript.

First of all, there is no item with the value "$250,000/$500,000" in your combo box, because we are checking for it, you probably need to add that.  You also should add an export value of "0" (without the quotes) for your first entry (the blank line). This will help to identify the blank entry.

The following steps are for Acrobat 8 Pro, if you are still using version 7, I can give you the menu items you need to use.

Select Advanced>Document Processing>Document JavaScripts on the Acrobate menubar. This will bring up the "JavaScript Functions" dialog. Type the name (without the quotes) "calculateTextField" into the Script Name field and then click on the "Add" button. This will bring up the editor with the function stab for the function already filled in. Just replace the whole thing with the script from below.

Then edit the properties of the text field and select the "Calculate" tab, select "Custom calculate script" and click on the "Edit" button. Add the following line:

calculateTextField();

Then edit the properties of the combo box and select the "Options" tab and check the "Commit selected value immediately" checkbox.

That should do it. Give it a try and let me know if you need anything else.




function calculateTextField()
{
    // get the value of the combo box
    var comboValue = this.getField("ComboBox95").value;
    // get the state of the checkbox
    var isChecked = (this.getField("Check Box97").value == "Yes");
    
    var textFieldValue = "";
console.println(comboValue);
    
    if (isChecked)
    {
        if (comboValue == 0)
        {
            textFieldValue = "";
        }
        else if (comboValue == "$250,000/$250,000")
        {
            textFieldValue = "N/A";
        }
        else if (comboValue == "$500,000/$500,000")
        {
            textFieldValue = "$500,000";
        }
        else if (comboValue == "$250,000/$500,000")
        {
            textFieldValue = "$500,000";
        }
        else
        {
            textFieldValue = "$1,000,000";
        }
    }
    else
    {
      textFieldValue = "";  
    }
    
    
    this.getField("Text97").value = textFieldValue;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Karl Heinz KremerCommented:
One more thing, remove the line with "console.println(comboValue)" from the script above, that was a line to output debug information to the JavaScript console (which you can bring up with Ctrl-J) in Acrobat.
0
cartereverettAuthor Commented:
khkremer,

Please check the attach file and tell me what I'm doing wrong.  I corrected the info within the combo box and added the 0 for the export value of the first option of the combo box and did everything else you asked  me to and it doesn't do anything.  Thanks buddy.
sample.pdf
0
Karl Heinz KremerCommented:
The combo box name in your form contains a space, when you reference that name in the document level javascript, you are using the name without the space, therefore the program cannot find the field. Either remove the space from the actual field name, or add the space to the reference in the program.
0
cartereverettAuthor Commented:
I was about to reply letting you know that I found the problem.  Thanks a whole lot for your help.  I might have some more stuff soon :)  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.