×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Adobe 9 text fields and calculations
2

Adobe 9 text fields and calculations

Adobe 9 text fields and calculations

(OP)
I am not well versed in Javascript.  Please be patient.
I am trying to have on field in adobe acrobat 9 populate from another fields input.  Basically if one field has an 18 in it I would like the other field to automatically populate with a +3.
Can anyone explain to me how to do this using the javascript custom calculation box?  Or any other way would work.  As long as I can do it.

Also:
I am trying to create a calculation form in Adobe acrobat 9.  I have an item named CHALEV.  I would like another textbox to calculate 1/2 (Round down) the number placed into CHALEV.  CHALEV is calcualted by taking the sum of 6 other fields.  I am pretty sure I need to use the command math.floor, but I do not know much about javascript and I do no know how to tell it to use the item calculated for the text box CHALEV.  Any help would be great.

I have 2 separate questions.  I am trying to create a working character sheet for SWRPG SE.   

RE: Adobe 9 text fields and calculations

2
Hi CecilXavier

If field1 = 18 then you want field2 to = 18 +3 or 21?
If so that would just be field2 = field1 + 3

Question 2
For CHALEV you make a field CHALEV2 or whatever and make the calculation  CHALEV2 = CHALEV * .50

Can you post what you have on the internet so I can see it?

IMacQuarker

RE: Adobe 9 text fields and calculations

(OP)
For Question 2:

It's in a pdf that I am using.  Let say I have 2 text boxes on this pdf.  One called CHALEV the other called CHALEV2.  Bare in mind this is just the name of the text field that I named it when adobe 9 asked what to name it.
I want, whenever I enter a value in CHALEV for it to calculate an output to CHALEV2 of .5 rounded down.
I believe I am going to use the math.floor() command.  Here is where I am having issues.  I either have to have a javascript calculation that exports from CHALEV to CHALEV2 or I need CHALEV2 to Read from CHALEV and calculate .5 rounded down.
I am used to having a field like CHALEV having a format of CHALEV.Text or CHALEV.input when I work in VB.  I am not used to how it works when editing a Adobe PDF

Question 1:

I basically want to make an if then statement.  If Str = 18 then Str Modifier = +3. If Str = 16 then Str Modifier = +2,  So forth and so on.  I don't know how the naming convension works when using javascript in an adobe pdf.  This is where I am lost.

Hope that clarifies what I am asking.

RE: Adobe 9 text fields and calculations

Hi CecilXavier

I am still not completely sure exactly what you want.
However if you want to do a number calculation you first have to format the text boxes to contain a number then you go to calculations and do the calculation.

This is what the following script does.
You should be able to modify it to do what you want.

If Str = 1, 2 or 3 then Str Modified = 3
If Str = 3, 4 or 5 then Str Modified = 4
If Str = 5, 6 or 7 then Str Modified = 5

Here is the script which you can change to what you want;
_____________________
var nstr = this.getField("str").value;
if( nstr < 1 )
    event.value = nstr = "";
else if( nstr <= 3 )
    event.value = nstr = 3;
else if( nstr <= 6 )
    event.value = nstr = 4;
else if( nstr <= 9 )
    event.value = nstr = 5;
else
    event.value = 0;
________________________________
Go here to see the PDF. You can download it and open it in Acrobat to see how it works.
http://www.nixmailmac.com/chalev.pdf

Hope this helps
IMacQuarker

RE: Adobe 9 text fields and calculations

(OP)
Smashing!  You answered my second question perfectly.  So the "this.getField("").value" command is how to get info from another txt box as a value and work with it correct?

RE: Adobe 9 text fields and calculations

(OP)
ok.  I think I messed up somewhere.  Here is the code I am using.

var nstr = this.getField("Str").value;
if( nstr < 1 )
    event.value = nstr = "";
else if( nstr = 1 )
    event.value = nstr = -5;
else if( nstr = 2 )
    event.value = nstr = -4;
else if( nstr = 3 )
    event.value = nstr = -4;
else if( nstr = 4 )
    event.value = nstr = -3;
else if( nstr = 5 )
    event.value = nstr = -3;
else if( nstr = 6 )
    event.value = nstr = -2;
else if( nstr = 7 )
    event.value = nstr = -2;
else if( nstr = 8 )
    event.value = nstr = -1;
else if( nstr = 9 )
    event.value = nstr = -1;
else if( nstr = 10 )
    event.value = nstr = 0;
else if( nstr = 11 )
    event.value = nstr = 0;
else if( nstr = 12 )
    event.value = nstr = 1;
else if( nstr = 13 )
    event.value = nstr = 1;
else if( nstr = 14 )
    event.value = nstr = 2;
else if( nstr = 15 )
    event.value = nstr = 2;
else if( nstr = 16 )
    event.value = nstr = 3;
else if( nstr = 17 )
    event.value = nstr = 3;
else if( nstr = 18 )
    event.value = nstr = 4;
else
    event.value = 0;

It keeps coming back with a value of -5 for Str Modifier.  What did I do wrong?

RE: Adobe 9 text fields and calculations

Hi CecilXavie

It looks like you have to have the less than/equal to symbols <= to make it work.
Also that script is case sensitive so you can't use Str for str.
I reposted the PDF and I think it works now.
You will have to change the result to whatever you want.

var nstr = this.getField("str").value;
if( nstr < 1 )
    event.value = nstr = "";
else if( nstr <= 1 )
    event.value = nstr = -1;
else if( nstr <= 2 )
    event.value = nstr = -2;
else if( nstr <= 4 )
    event.value = nstr = -4;
else if( nstr <= 5 )
    event.value = nstr = -5;
else if( nstr <= 6 )
    event.value = nstr = -6;
else if( nstr <= 7 )
    event.value = nstr = -7;
else if( nstr <= 8 )
    event.value = nstr = -8;
else if( nstr <= 9 )
    event.value = nstr = -9;
else if( nstr <= 10 )
    event.value = nstr = -10;
else if( nstr <= 10 )
    event.value = nstr = -10;
else if( nstr <= 11 )
    event.value = nstr = -11;
else if( nstr <= 12 )
    event.value = nstr = -12;
else if( nstr <= 13 )
    event.value = nstr = -13;
else if( nstr <= 14 )
    event.value = nstr = -14;
else if( nstr <= 15 )
    event.value = nstr = -15;
else if( nstr <= 16 )
    event.value = nstr = -16;
else if( nstr <= 17 )
    event.value = nstr = -17;
else if( nstr <= 18 )
    event.value = nstr = -18;
else
    event.value = 0;

Go here

http://www.nixmailmac.com/chalev.pdf

IMacQuarker

RE: Adobe 9 text fields and calculations

(OP)
OK.  Here is what I am trying to do with the CHALEV.

var level = CHALEV.value
event.field = Math.floor(level * .5)

I know I have this all wrong.  I'm trying to take the Value of CHALEV and divide it in half.  Rounding down.

Everything else works great now.  Thank you.

RE: Adobe 9 text fields and calculations

Hi CecilXavier

I think I found a way to make the round down to work.
Try this
The Simplified field notation for Chalev2 = Chalev * .50
Then to round it down you go to Validate and paste this
event.value = Math.floor(event.value);
That seems to work here.
Try it
http://www.nixmailmac.com/chalev.pdf

IMacQuarker

RE: Adobe 9 text fields and calculations

(OP)
Worked like a charm.  Thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close