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

HELP: one javascript calculation field affecting entire form...

kp
Registered: Jun 16 2009
Posts: 7

This is the message that pops up:
Warning Javascript Window - The value entered does not match the format of the field [ ResultsC ]

The issue is: I have created a form with many types of fields; text, calculation etc. I needed to create a form field to do a division calculation. There is no preset division option under the calculate tab so I created a simplified field notation of TotalC / TotalG for my ResultsC field. The calculation worked and I was quite excited!

However, when going to troubleshoot my form I run into the above error upon tabing out of every single other field that I try to enter information in to. I don't know what to do to fix this. There are only four fields that have anything to do with the javascript calculation.

Any suggestions/ideas?

Thank you!!!

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Do [b]not[/b] divide by zero!

You will have to write a 'Custom JavaScript calculation script' to prevent division by zero.

George Kaiser

kp
Registered: Jun 16 2009
Posts: 7
Okay.
I am quite inexperienced at this and have just being working by trial and error.
How does this script differ from the simplfied notation?
kp
Registered: Jun 16 2009
Posts: 7
SO...I have entered the following custom javascript as mentioned above:
event.value = this.getField("Text1").value / this.getField("Text2").value

I still get the same error message when I tab out of the other fields on the form. There are a combination of text fields and number fields on this particular form. I only have about four fields that are connected to this calculation.

Any other suggestions?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You still have to test to make sure you are not divisor is not zero and then only perform the computation when the divisor is not zero.

event.value = ''; // clear the resultif (this.getField("Text2").value !=0) {// divisor is not zero, so the calcualtion can be performedevent.value = this.getField("Text1").value /  this.getField("Text2").value;} else {//  action for a zero divisorevent.value = ''; // null result field}

George Kaiser

kp
Registered: Jun 16 2009
Posts: 7
yes I understand now. And it looks like it is working. The field was trying to calculate on the default values(which of course were zero) before information was entered. The calculate fields are not the first ones on the form.

Thank you very much.