Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Checkboxes and text fields

Posted on 2004-10-20
16
Medium Priority
?
298 Views
Last Modified: 2008-02-26
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!
0
Comment
Question by:jks709
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
16 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12361663
How do you calculater the sum? Are you already using JavaScript for this?

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.
0
 

Author Comment

by:jks709
ID: 12361785
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"
0
 

Author Comment

by:jks709
ID: 12362006
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
}
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jks709
ID: 12362657
is anyone out there?!?! : (
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12363005
Yes, but not always online, and also not always near a computer with Acrobat. I'll be back shortly...
0
 

Author Comment

by:jks709
ID: 12363068
no problem...i'm just sad that i can't find too much info on this out on the Net.
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 1280 total points
ID: 12363150
This is an example for a calculation script that would go into the "tax value" field:

var needTax = (this.getField("CheckTax").value == "Yes");
if (needTax)
{
    event.value = (this.getField("Text1").value + this.getField("Text2").value) * 0.06;
}
else
{
   event.value = 0;
}

You can certainly also use your subtotal field instead of adding up the two field that I used. The key is to set the event.value to 0 when the checkbox is not checked.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12363187
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

0
 

Author Comment

by:jks709
ID: 12363225
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.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12363301
It works for me. Open up the JavaScript debugger  (Ctrl-J, or use the menu item). Do you see any error messages?
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12363317
Which version of Acrobat are you using?
0
 

Author Comment

by:jks709
ID: 12369020
I'm using 6.0.  I'll try the debugger and see what happens.
0
 

Author Comment

by:jks709
ID: 12369354
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!!!
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12369384
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.
0
 

Author Comment

by:jks709
ID: 12370288
Really?!! when I program for the web the JavaScript isn't case sensitive...
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12370685
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Getting information about Fonts being used in a PDF file A colleague of mine recently faced an issue related to the PDF file format. The PDFs were containing mission critical client information, they were successfully mailed but there was a sm…
This article explains how to perform batch conversion of PDF, TIFF, and other image file formats into PDF, PDF Searchable, and TIFF files via a command line interface, using Nuance's latest document imaging software — Power PDF Advanced.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question