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

Tricky code, checkboxes in a table.

troll
Registered: Apr 12 2010
Posts: 2

I'm quite new at this.
It's 3 check boxes for each row, with different javascript, scripts is working, but I'd like to have them in document level. Anybody want to help?
A.1-C.3 and so on to C.31(31 rows)
A.1 script ;
this.getField("inn.1").value = this.getField("ut.1").value
this.getField("P.1").value = this.getField("ut.1").value * 0.20

VarA = this.getField("P.1").value;

VarA = this.getField("P.1").value;
if(VarA < 0) this.getField("b.1").value = (VarA);
if(VarA > 0) this.getField("a.1").value = (VarA);

B.1 script;
this.getField("P.1").value = (this.getField("ut.1").value) * 0.25;
this.getField("inn.1").value = this.getField("ut.1").value + this.getField("P.1").value;

VarA = this.getField("P.1").value;

if(VarA < 0) this.getField("b.1").value = (VarA);
if(VarA > 0) this.getField("a.1").value = (VarA);

C.1 script
this.getField("inn.1").value = this.getField("ut.1").value
this.getField("c.1").value = this.getField("ut.1").value

This is working, but it's been more simple to create a document level script and just call the script for A, B or C, at each row, how do I do this.

This form I use to summarize 2 accounts to find correct difference. The P Field is VAT, and some numbers is with no VAT (C), included VAT (A) or should be calculated with VAT (B)

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You can get a field name as a variable using the 'event.target.name' method. The following document level function can display information about your check boxes when used with a field level action script.
function ShowFieldName() {// get field namevar sFieldName = event.target.name;// make an array of the field namevar aFieldName = sFieldName.split('.'); // build display string// the field namevar sMsg = "This field's name is: " + sFieldName; // levels of field namesMsg += "\n\nThe field's name array has " + aFieldName.length + ' elements';// each level name of fieldsMsg += '\n\nThe elements are:';for (i = 0; i < aFieldName.length; i++) {sMsg +='\n' + i +': ' + aFieldName[i];} // display massageapp.alert(sMsg, 3, 0);return;}}

For your check boxes you can use the following 'Mouse Up' action.
ShowFieldName()

George Kaiser

troll
Registered: Apr 12 2010
Posts: 2
Code is working as you have written, Java script window :"This field's name is: JA.8

The field's name array has 2 elements

The elements are:

0: JA

1:8"

Nicely done, but still I'm a little confused