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

Forcing recalculation of field after check box selection changed?

Aerial
Registered: Nov 11 2010
Posts: 4
Answered

There come a time when one must admit that help is needed.... I'm there.
 
I have a form I am developing which will calculate the cost of an event based on various factors - some directly entered as numbers, other choices being made through check boxes. The check box choices will determine which calculation fields are used (the check boxes determine which types of spaces are to be used for the event, thereby setting which costs should be calculated.)
 
I have gotten this far:
 
(getField("cole").value == "Off")
? (event.value = null)
: ((+getField("evnthrs").value < 5)
? event.value = 5
: event.value = +getField("evnthrs").value);
 
This script allows the Hours of the event ("evnthrs") - this space "cole" has a 5 hour minimum charge, hence the comparision - to be placed in the field to included in calculating the total, and it works in that it calculates and assigns the value once the "cole" box is checked.
 
My problem is this - it doesn't update and remove the value if the box is later unchecked.
 
I'm fairly certain that I am just missing something in my efforts to find something in the documentation about how to force the fields to recalculate... Can someone please tell me where it might be?
 
Thanks!

- -
Beth Harris

My Product Information:
Acrobat Pro 8.1.6, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Is there something missing from the script as it's shown above?
Aerial
Registered: Nov 11 2010
Posts: 4
Other than the spacing that was removed in the formatting, no. That is exactly what is in the Custom Calculation area for the field in question.

- -
Beth Harris

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Instead of setting event.value to null, set it to an empty string: event.value = ""

If that doesn't work, I could suggest a slight re-write of that code.
Aerial
Registered: Nov 11 2010
Posts: 4
I knew there had to be something simple I was missing...... THANK YOU!!!!! Changing null to "" works!!

I am interested in your possible re-write though.... if you would care to share?

- -
Beth Harris

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you opened the JavaScript debugging console and looked for any errors?

Using compressed coding techniques or options, makes debugging much harder. Why not just write out the code in a clearer manner:

event.value = '';
if(this.getField('cole').value != 'Off') {
event.value = 5;
if (this.getField('evnthrs').value > 5)
event.value = this.getField('evnthrs').value;
}


George Kaiser

Aerial
Registered: Nov 11 2010
Posts: 4
I had started off in that direction, but in the frustration of getting the code to work in the first place, I ended up with the compressed version because that was the first one that worked.

Now that I have the full thing working, I will probably move it back into the structured setup.

Thanks so much for the help! I appreciate it greatly!

- -
Beth Harris