I'm trying to find the correct code which will write selected check box field names to a text box in a LiveCyle form. I've taken the javascript course at W3Schools.com, but it is a very basic course designed for HTML applications. I'm thinking that what I need is some use of the click event and getElementsByName(id)function but I've been unable after many tries to make it work at all.
My form consists of a number of check boxes on page 1 we can say are labeled answer1 thru answer5 in their respective field names. Upon the user selecting boxes, for example, answer1, answer3 and answer4, a target text box on page two will list the correcponding field names of each checkbox.
I'd like to use a button labeled "Update" at the bottom of the page 1 checkbox list which will initiate an event to first clear the page 2 text box of previous entries (if any) before populating it with all the new selected entries from page 1.
I hope someone can help me out. If this question has been answered already I apologize. I went back through old posts pretty far and didn't see any. Thanks.
Next, you should get some LiveCycle and Acrobat specific JavaScript training. You'll find videos and articles on this site as well as www.pdfscripting.com
Here's a good one:
http://adobechats.adobe.acrobat.com/p87746471/
Now, there are few different techniques for approaching this problem. But the easiest and most straight forward is to just write a series of "if" statements that test the check boxes. The code can be placed on the click event of your update button, or it could be placed on the calculate event of the text field where the list of check boxes is displayed.
MycheckSummary.rawValue = ""; // Clear summary of check boxes
if(MyCheck1.rawValue == "1")
MycheckSummary.rawValue += "MyCheck1, ";
if(MyCheck2.rawValue == "1")
MycheckSummary.rawValue += "MyCheck2, ";
A more sophisticated and generalized technique would be to name/structure the checkboxes in such a way that they could be collected by the resolveNodes() function.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script