I’ve got a little over three-months experience with Adobe LiveCycle.
I have a row of three-text field items which I’d like to enable/disable based on a checkbox.
So if Checkbox-1 == 0 then Field-1, Field-2, Field-3 will be disabled
else Checkbox-1 == 1 then Field-1, Field-2, Field-3 will be enabled & required
I'm also trying to determine which item under the "Show" drop down that this script will need to be placed.
Any help would be greatly appreciated,
Andy
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Andy,
Here is a sample where the required status of the checkboxes changes if any one of them is checked: https://acrobat.com/#d=J0KsvCyW0s4qUECdSXMEdQ
You access the mandatory property - 'error' sets a field to required, whereas 'disabled' is not required. So this would make a textfield required:
TextField1.mandatory = "error";
Whereas this would make a field not required:
TextField1.mandatory = "disabled";
The other aspect you are looking for is whether the user can input data, which requires the access property. This makes the field available:
TextField1.access = "open";
Whereas this makes it unavailable:
TextField1.access = "readOnly";
So for your form, I would put the following script in the click event of the checkbox:
if (this.rawValue == "0")
{
Textfield1.access = "readOnly";
Textfield2.access = "readOnly";
Textfield3.access = "readOnly";
Textfield1.mandatory = "disabled";
Textfield2.mandatory = "disabled";
Textfield3.mandatory = "disabled";
}
else
{
Textfield1.access = "open";
Textfield2.access = "open";
Textfield3.access = "open";
Textfield1.mandatory = "error";
Textfield2.mandatory = "error";
Textfield3.mandatory = "error";
}
I hope that helps,
Niall
Views
Replies
Total Likes
Hi Andy,
Here is a sample where the required status of the checkboxes changes if any one of them is checked: https://acrobat.com/#d=J0KsvCyW0s4qUECdSXMEdQ
You access the mandatory property - 'error' sets a field to required, whereas 'disabled' is not required. So this would make a textfield required:
TextField1.mandatory = "error";
Whereas this would make a field not required:
TextField1.mandatory = "disabled";
The other aspect you are looking for is whether the user can input data, which requires the access property. This makes the field available:
TextField1.access = "open";
Whereas this makes it unavailable:
TextField1.access = "readOnly";
So for your form, I would put the following script in the click event of the checkbox:
if (this.rawValue == "0")
{
Textfield1.access = "readOnly";
Textfield2.access = "readOnly";
Textfield3.access = "readOnly";
Textfield1.mandatory = "disabled";
Textfield2.mandatory = "disabled";
Textfield3.mandatory = "disabled";
}
else
{
Textfield1.access = "open";
Textfield2.access = "open";
Textfield3.access = "open";
Textfield1.mandatory = "error";
Textfield2.mandatory = "error";
Textfield3.mandatory = "error";
}
I hope that helps,
Niall
Views
Replies
Total Likes
Worked perfectly! Just had to copy the first part of the if statement to the initialize so the form was disabled on load until a user selects the appropriate check box.
Thanks again,
Andrew
Views
Replies
Total Likes
You're welcome
The code above worked great for single checkbox(s) but I have a radiobutton which I’d like to produce similar results.
My radio button has seven-options and two of them I’d like to require additional information if selected.
If (this.rawValue == “6”,”7”)
{
TextField6.access == “readOnly”;
TextField6.mandatory ==”disabled”;
TextField7.access == “readOnly”;
TextField7.mandatory ==”disabled”;
}
else
{
TextField6.access = “open”;
TextField6.mandatory = “error”;
TextField7.access = “open”;
TextField7.mandatory = “error”;
}
I’m trying to input this script into the ‘RadioButton1’ however it doesn’t appear that I can do this…do I have to edit each “button”? Such as RadioButton1.First and so on and input the code…that didn’t work either….
Any help would be a tremendous time saver,
Andrew
Views
Replies
Total Likes
Hi Andrew,
When dealing with radiobuttons it is best to place the script in the click event of the radio button group and not the individual radio buttons.
When testing against multiple conditions you need to explicitly state each one. For example a radio button group can only have one value so you are looking to see if it is '6' or '7'.
Please note that && means 'and', || means 'or'
if (this.rawValue == “6” || this.rawValue == ”7”)
{
TextField6.access == “readOnly”;
TextField6.mandatory ==”disabled”;
TextField7.access == “readOnly”;
TextField7.mandatory ==”disabled”;
}
else
{
TextField6.access = “open”;
TextField6.mandatory = “error”;
TextField7.access = “open”;
TextField7.mandatory = “error”;
}
You can build more complex tests by wrapping in brackets:
if (TextField1.rawValue == "Apples" || (TextField1.rawValue == "Oranges" && DropDown1.rawValue == "Not in stock"))
{
...
}
Hope that helps,
Niall
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies