So the preface here is that I'm new to Adobe forms, specifically LifeCycle Designer (8). I do have some JS under my belt but it's rusty.
I need to evaluate a radio button's (group called rb) value (Yes or 1 is called rby and No or 0 is rbn) to determine what the user selected. If they select Yes, I need to set the property of 3 checkboxes to required (script1). Ideally, I'd like to take this a step further and gray out said checkboxes and un-gray them when the user chooses Yes (since the default is No). The user may tab through or mouse wherever they need to on the form so I "thought" that:
1. script1 should be written in the validate or exit event of the radio button but I tried doing this in both events for rb and rby and the script doesn't trigger (whether I tab through, mouse through or hit my submit button). See script below, which may be written incorrectly and therefore responsible for the script to fail.
2. A second script on my submit button's validate event could be used to make sure that the combination of the radio button's value of Yes and one of 3 checkboxes being checked off occurred before the form is submitted. A discussion to follow later.
I've tried a variety of tactics which all failed. So I'm hoping some kind soul can provide me with newbie step by step instructions as to where my JS should be written and a sample of code that demonstrates how I might accomplish the above.
This, at least, will point me where I'm supposed to go rather than what has so far been a very extensive trial by error process that has yielded no results.
This is the JS I tried for script1:
var RBt = this.getField("rb");
if (RBt.value == true)
{
app.alert("rb is Yes."); //to tell me if the test was triggered
var CBr = getField("CB1");
CB.required = true;
var CBr = getField("CB2");
CB.required = true;
var CBr = getField("CB3");
CB.required = true;
}
Any help?
First, since this is for a radio button the script should be on the Click event. The radio button values should be 1 and 2. And there is no "required" property on LiveCycle form elements. Instead they use the "mandatory" property. So, the script should look something like this.
if(this.rawValue == 1)
{
CB1.mandatory = "error";
CB2.mandatory = "error";
CB3.mandatory = "error";
}
To learn about graying out fields see this article.
http://acrobatusers.com/tutorials/2007/09/js_disabling_fields
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script