Copy link to clipboard
Copied
I'm trying to make a pdf that when you check certain boxes a section of the doc will highlight.
I thought the best way to go about it is to use the lineWidth of a text box. Not sure if that IS the best way it was just a thought...
But I want to border to be hidden first then when a checkbox is checked it will be visible. if the box is unchecked it goes back to hidden.
I've tried this in the checkbox action:
var checkBox1 = getField("CheckBox1").value;
var bord = getField("bordr1");
bord.lineWidth = 0;
if (checkBox1 = "Yes") {
bord.lineWidth = 3;
}
else {
bord.lineWidth = 0;
}
but it doesn't work. couple questions
is there a way to just write code instead of putting it in actions?
if not how can I hide the text box by default? and still be able to display it later?
Remove line #3 from your code.
Also, you used the wrong operator in line #5. It should be:
if (checkBox1 == "Yes") {
Regarding the execution of the code: It can be done from several places. For testing purposes you can run it from the JS Console.
Press Ctrl+J to open it, then paste the code into it, select all of it using the mouse or keyboard and press Ctrl+Enter to run it.
Copy link to clipboard
Copied
Remove line #3 from your code.
Also, you used the wrong operator in line #5. It should be:
if (checkBox1 == "Yes") {
Regarding the execution of the code: It can be done from several places. For testing purposes you can run it from the JS Console.
Press Ctrl+J to open it, then paste the code into it, select all of it using the mouse or keyboard and press Ctrl+Enter to run it.
Copy link to clipboard
Copied
Thank you! That worked as I wanted it to.
Copy link to clipboard
Copied
So. now that is working I tried to translate to multiple checkboxes.
Basically I have three checkboxes and if any of them are checked then I want the box to show the border. I'm still trying to type the code in the properties -> actions area since the "All javascript" part adds XML that I'm not exactly sure what its used for so I don't want to change it or create something without it... Basically I'm typing the below code into the actions of each checkbox which seems redundant but I don't know any other way to do it. The console is great when trying things out but what do I do when I want to send this PDF to someone? other than actions where does the code go?
so, anyway, here is the code I'm trying. ( I DID change the value in each check box from "Yes" to "3")
var cb1 = getField("CheckBox1").value;
var cb2 = getField("CheckBox2").value;
var cb3 = getField("CheckBox3").value;
var bord = getField("bordr1");
if (cb1 ^ cb2 ^ cb3 == "3") {
bord.lineWidth = 3;
bord.display = display.visible;
}
else {
bord.display = display.hidden;
}
this works to a point. I can check each box individually and get the border. I can check the "first and third", and the "second and third" but when I check the "first and second" the border turns back off when the second box is checked. I'm confused as to why this is happening, Any thoughts?
Copy link to clipboard
Copied
What did you try to express with this symbol "^"?
Copy link to clipboard
Copied
That is the Exclusive OR bitwise operator.
Copy link to clipboard
Copied
ok well... A single pipe seems to work. For some reason I was reading that the standard or operator was a double pipe. this is all pretty new to me still.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now