jks709
asked on
Checkboxes and text fields
Hi,
I'm creating a form in adobe acrobat. It is to purchase studies. I have a field for the subtotal of the order and I have a field for tax however the tax is only applied to NJ residents so I would want a checkbox next to the textbox that activates the text box. i.e. if the person lives in NJ, they check off the box and the textbox automatically calculates the 6% sales tax but if the checkbox is not checked I would want the textbox to be unactive. Do you know if this is possible and how I can work it? I've searched all over the internet and can't find any answers. Thanks in advance!
I'm creating a form in adobe acrobat. It is to purchase studies. I have a field for the subtotal of the order and I have a field for tax however the tax is only applied to NJ residents so I would want a checkbox next to the textbox that activates the text box. i.e. if the person lives in NJ, they check off the box and the textbox automatically calculates the 6% sales tax but if the checkbox is not checked I would want the textbox to be unactive. Do you know if this is possible and how I can work it? I've searched all over the internet and can't find any answers. Thanks in advance!
ASKER
Yes, I'm using JavaScript to calculate the subtotal and the total, it's just adding the fields together. I'm not sure how you would code the... "if the checkbox is enabled, and if it is, calculate the tax, enable the field for the tax, print the tax amount in this field, and add it to the total"
ASKER
This is what I have now and it's not working:
var f = this.getField("check");
var x = this.getField ("subtotal");
if f = "Yes"
{
event.value = .06 * x
}
var f = this.getField("check");
var x = this.getField ("subtotal");
if f = "Yes"
{
event.value = .06 * x
}
ASKER
is anyone out there?!?! : (
Yes, but not always online, and also not always near a computer with Acrobat. I'll be back shortly...
ASKER
no problem...i'm just sad that i can't find too much info on this out on the Net.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are two things you need: A JavaScript tutorial that covers the core JavaScript language (your compare statement is syntactically wrong), and then you need the Acrobat JavaScript reference, which you can download here: http://partners.adobe.com/asn/acrobat/docs.jsp#javascript
ASKER
I just tried it. It still doesn't work...I modified the code to correspond with the names of my textboxes and i tested it....i put a value in the subtotal field and checked off the box and nothing happened.
It works for me. Open up the JavaScript debugger (Ctrl-J, or use the menu item). Do you see any error messages?
Which version of Acrobat are you using?
ASKER
I'm using 6.0. I'll try the debugger and see what happens.
ASKER
YAY...it works!!! I realize now that Acrobat is VERY case-sensitive...I had "checkTax" for the checkbox name and "CheckTax" i my script. I can't thank you enough for your help!!!
It's not Acrobat, it's JavaScript that's case sensitive. If you want to work more with JavaScript, you really should look into a good book/online-tutorial about the core JavaScript language.
ASKER
Really?!! when I program for the web the JavaScript isn't case sensitive...
JS is case sensitive:
http://www.webreference.com/programming/javascript/jsdesign/chap2/
http://academ.hvcc.edu/~kantopet/javascript/index.php?page=js+syntax&parent=core+javascript&printme=true
(scroll down to the section titled "Case Sensitivity" on both pages)
http://www.webreference.com/programming/javascript/jsdesign/chap2/
http://academ.hvcc.edu/~kantopet/javascript/index.php?page=js+syntax&parent=core+javascript&printme=true
(scroll down to the section titled "Case Sensitivity" on both pages)
If you do, it's simple: In your routine that calculates the sum, just check if the checkbox is enabled, and if it is, calculate the tax, enable the field for the tax, print the tax amount in this field, and add it to the total.
If you are not yet using JavaScript, it's a bit more involved ... But before I describe the procedure, I'd like to know if it's neccessary.