3 Replies Latest reply on Nov 22, 2012 2:50 PM by DarthAngelus

# Got another form equation I need...

If you all couldn't tell, my Java ability is basic... at best.

Now, I'm sure you're all going to be 'This is so simple! What an idiot!', but I can't seem to get it to work properly.

I need an equation for my form so that one field will display a value when a value is inserted into another field. Something like:

If LEVEL = X then XP = Y.

And I need it so that it goes up to 30. i.e LEVEL = 1 then XP = 1,000, LEVEL = 2 then XP = 2,250, etc., etc.

I also need an equation so that when a certain field reaches a certain value, another field changes its value.

If XPUP = or > A then LEVEL = B

And, again, I need it to go to 30. i.e. If XPUP = or > 1000 then LEVEL = 2, If XPUP = or > 2250 then LEVEL = 3, etc., etc.

(If you couldn't tell or are curious why, I'm trying to get an Interactive character sheet for Dungeons & Dragons that automatically determines your level and how much XP is needed for the next level based on your XP value.)

Thanks for all your help guys!

• ###### 1. Re: Got another form equation I need...

So let's say you have a field called XP, and another one called LEVEL. You can enter this code as the custom calcluation for LEVEL:

var xp = +this.getField("XP").value;

if (xp>0 && xp<30)

event.value = 1;

else if (xp>30 && xp<50)

event.value = 2;

etc.

By the way, there's another person here who's developing PDF forms for D&D, maybe you two can collaborate... He's called GameHermit.

• ###### 2. Re: Got another form equation I need...

And by the way, it is JavaScript. It's a good idea never to abbreviate it to Java, because Java is a completely different language. That really matters when you're searching for examples and stuff on the web.

• ###### 3. Re: Got another form equation I need...

Sorry about that... You know, I knew that too, but it is what it is, eh?

Anyway, thanks for your help; your equation solved both my problems. Thanks alot.