Copy link to clipboard
Copied
First off, I'm using checkboxes as a radiobutton in this example.
I have a series of checkboxes all named "Finish1" When I select a specific checkbox in the "Finsh1" set, I want it to look at the export values of another group of checkboxes named "Color1" and hide specific ones. What I have attempted below I'm sure is a mess and it doesn't work, but it was my best idea.
Thank you for your help!
var vc = this.getField("Color1").value;
if(vc == 3 || vc == 5 || vc == 8 || vc == 12 || vc == 13 || vc == 14 || vc == 18 || vc == 19 || vc == 20) {
vc.display = display.hidden ;
}
else if(vc == 3 || vc == 5 || vc == 8 || vc == 12 || vc == 13 || vc == 14 || vc == 18 || vc == 19 || vc == 20) {
vc.display = display.visible ;
}
What I was thinking, was when a finish was selected, it would show all of the "Color1" checkboxes, except those that were not available in that finish. So, when a finish is selected, specific colors would not be visible.
It is not possible to hide specific checkboxes that are all named the same. The only way to get this to work is to rename them and hide or show what you want, then reset the checkbox, assuming you wanted them to react like a radiobutton.
Thanks again try67 for all of your efforts
...Copy link to clipboard
Copied
Should it not take the value of Finish1 itself into consideration?
Copy link to clipboard
Copied
You made a mistake because you're treating the vc variable as a field, when in fact it's the field's value.
Also, your code doesn't make sense. The conditions under the if-statement and under the else-statement that follows it are identical...
Copy link to clipboard
Copied
I guess I do need the value of "Finish1" if I'm using the following method. I was just trying to see if I could get the checkboxes to hide, but I had no luck using this.
var f1 = this.getField("Finish1").value ;
var c1 = this.getField("Color1").value ;
if(f1 == 4 && c1 == 3) {
c1.display = display.hidden ;
}
I copy and pasted the upper half of the code and I meant to change it before posting, but I got side tracked.
How would I go about pulling the value of the "Color1" checkbox set, then turning off specific ones based on their export value?
Copy link to clipboard
Copied
You're still making the same mistake as before... Your code needs to be something like this:
var f1 = this.getField("Finish1");
var c1 = this.getField("Color1");
if (Number(f1.value) == 4 && Number(c1.value) == 3) {
c1.display = display.hidden ;
}
Copy link to clipboard
Copied
I was hopeful that would work, it made a bit more sense, but unfortunately that didn't work either.
I get no response from any of the checkboxes. Is it even possible to hide and show a checkbox / radio button that has the same name? (i.e. "Color1")
Here's an image of what it looks like.
Copy link to clipboard
Copied
Are you sure you set the export values of the check-boxes (or radio-buttons) to these values?
Also, check the JS console for any error messages.
And yes, it is possible to do it.
Copy link to clipboard
Copied
The error messages when entering the code into the console are:
SyntaxError: syntax error
1:Console:Exec
undefined
Edit: I still get the SytaxError, sometimes, seems to be a PDF bug. No other code changes.
I added "" to the code, and it removed the SytaxError, but the undefined remained.
The export value of "Finish1" is 4 and the export value of "Color1" is 3. They go in numerical order, so the ease of targeting specific colors would be easier.
Copy link to clipboard
Copied
I don't understand. Did you change the code I provided? If so, why and how?
Copy link to clipboard
Copied
When I originally added your code it gave me the SytaxError, so I added "", which then removed the SytaxError. This is what it looked like, but it still didn't fix anything and nothing reacted after changing it. So it didn't help or break anything what I did.
if (Number("f1.value") == 4 && Number("c1.value") == 3) {
c1.display = display.hidden ;
Closing and re-opening the document then re-entering your code only returned "undefined". So I'm not sure what is happening.
Copy link to clipboard
Copied
The original code I provided is fine, if you use it as is. Make sure you don't change the type of quotes used in it or anything else.
Your changes actually broke it. And a return value of "undefined" only means the code executed without error and without returning any values.
Copy link to clipboard
Copied
I tried it as is from your original post, as I had the first time, and still no luck. Nothing has changed or indicated it was working.
Copy link to clipboard
Copied
How are you running the code? Can you share the file?
Copy link to clipboard
Copied
I'm running the code in the actions tab of the "Finish1" checkbox (As shown in the picture I posted. I can share it, but I can't share it in a public forum, I will send you a pm message with a link to the file.
Copy link to clipboard
Copied
What I was thinking, was when a finish was selected, it would show all of the "Color1" checkboxes, except those that were not available in that finish. So, when a finish is selected, specific colors would not be visible.
It is not possible to hide specific checkboxes that are all named the same. The only way to get this to work is to rename them and hide or show what you want, then reset the checkbox, assuming you wanted them to react like a radiobutton.
Thanks again try67 for all of your efforts! A valuable asset to the forum!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now