Copy link to clipboard
Copied
Hello. I would like to use four check boxes in a form, each of which will activate (check) if data has been entered into four separate form text fields on a different page in the same form.
Example:
Page 1 will have a question such as... How many apples did you eat last month? "text1" = 3
So, since the user answered 3 in form "text1" field, "checkbox1" should now be checked on page 2.
... and so on for the other three.
Note: The answers to the questions will all be as a number. If the user enters 0 (zero) then I do not want the check boxes to activate. So any answer greater than zero will check the checkbox.
Follow up question...
Is it possible for an entirely different form text field to be visible or not visible (with default read only text) based on the status of each checkbox mentioned above?
Example:
"checkbox1" will have a text field next to it named "date1" with a hidden date. If "checkbox1" is checked (due to the actions above) then the date will be visible.
... and so on for the other three.
Thank you so much!
- You can use something like this as the custom validation script of your text field:
if (event.value=="3") this.getField("checkbox1").checkThisBox(0, true);
- Yes, but you shouldn't make it dependent on the check-box, but incorporate it into the script above, like this:
if (event.value=="3") {
this.getField("checkbox1").checkThisBox(0, true);
this.getField("date1").display = display.visible;
} else {
this.getField("date1").display = display.hidden;
}
If you also want to un-check the
...Copy link to clipboard
Copied
- You can use something like this as the custom validation script of your text field:
if (event.value=="3") this.getField("checkbox1").checkThisBox(0, true);
- Yes, but you shouldn't make it dependent on the check-box, but incorporate it into the script above, like this:
if (event.value=="3") {
this.getField("checkbox1").checkThisBox(0, true);
this.getField("date1").display = display.visible;
} else {
this.getField("date1").display = display.hidden;
}
If you also want to un-check the check-box in case the value of the text field is not 3 then duplicate line #2 but with false instead of true in the else-block.
Copy link to clipboard
Copied
Thank you for the reply try67! I will work with this code tonight. What if the answer was any number greater than zero? Can I change the code to read ">0" instead of "3"?
Thank you.
Copy link to clipboard
Copied
Yes, but then you need to make sure it's an actual number, so it should be:
if (Number(event.value)>0) {
Copy link to clipboard
Copied
Thanks a bunch try67!
I was able to get this to work the way I wanted it to thanks to your help. I had to experiment a bit to get the checkbox1 to toggle. I wound up using the code below...
//Script to check the box and display a date if number is greater than zero
if (Number(event.value)>0) {
this.getField("checkbox1").checkThisBox(0, true);
this.getField("date1").display = display.visible;
} else {
this.getField("date1").display = display.hidden;
}
// script below to uncheck the box if value is zero
if (event.value=="0") {
this.getField("checkbox1").checkThisBox(0, false);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now