Hi, started using Acrobat and tried to learn how to make forms for the first time yesterday.
Really sorry, these questions are bound to have been covered but I did spend a good 2 hours searching the forums and whereas I learnt a lot, I just couldn't seem to get my syntax correct for a problem I have with a form calculation.
I have 2 queries, the first probably a very easy one.
1)
I have a text field called MLS1, users of the form can fill in the value but let's say they enter 100.
I have another field called MLSBox which is a checkbox.
I have a another text field called MLSTotal.
I want the ticking of the checkbox to enter the value from the MLS1 field into the MLSTotal box.
So if the MLS1 field says 100, and the checkbox is checked, the MLSTotal box should also say 100.
Also if the checkbox is unchecked, I want the MLSTotal box to say 0.
I've come close to making this work but not quite there and my brain can't take any more! Part of my confusion lies in whether I'm meant to be writing the script in the MLSBox or MLSTotal fields.
2)
A bit more complex, probably?
I have a text field called IDK1
I have a drop down menu field numbered 0-8 called IDKBox
I have a text field called IDKTotal
Don't know where to even begin on this one.
I want it to be the case that if I select '1' from the drop down menu, the value from field IDK1 is copied into IDKTotal.
However, when numbers 2-8 are selected, it needs to add 75 each time to the value in IDKTotal, rather than take the product from IDK1 and multiply it by the IDKBox value.
So if IDK1 says 200, I want it to be the case that by selecting '1' from the drop down, 200 is entered into IDKTotal.
But if '2' is selected, I want IDKTotal to say 275, '3' to say '350' etc.
And again, if '0' is selected, IDKTotal to say 0.
Is that possible at all?
Incidentally I'm using Acrobat X Pro.
Thank you very much in advance for any assistance you can provide!
if (getField("MLSBox").value=="Yes") // if the check-box is ticked
event.value = getField("MLS1").value; // ...copy the value of MLS1
else event.value = "0"; // otherwise, reset this field.
2. You can use something like this as the custom-calculation script of IDKTotal:
event.value = Number(getField("IDK1").value) * Number(getField("IDKBox").value);
This is enough because if "0" is selected, the result will be 0. If "1" is selected, the result is the value of IDK1, etc.
We just need to convert the values to real numbers, which is what the Number() function does.
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com