Copy link to clipboard
Copied
Hi There,
I have a Checkbox that activates a calculation in a Text field. I would like another Checkbox, multiple in fact, to activate the initial Checkbox. If any or all of the others are checked, it will check the box and activate the field.
I don't see a place to enter a script in a checkbox is my first problem.
Please advise.
Thansk!
~Marc
Copy link to clipboard
Copied
If all checkboxes need to be checked to check checkbox for calculation perhaps it would be better to use hidden text field and use 'custom calculation script'.
EDIT: if any check box will checked it you can use this in all checkboxes as 'Mouse UP' event under 'actions' tab:
this.getField("Checkbox").checkThisBox(0,true);
Change "Checkbox" to your actual checkbox name.
Copy link to clipboard
Copied
Select 'Run a JavaScript' then click 'add' and paste script inside.
Copy link to clipboard
Copied
In that case use this script instead it will check/uncheck checkbox:
this.getField("Checkbox").checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
Rename your first checkbox from "Check Box" to "Check Box1" other checkboxes leave as they are and use this script:
for( var i=1; i<=7; i++)
this.getField("Check Box"+i).checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
If all checkboxes need to be checked to check checkbox for calculation perhaps it would be better to use hidden text field and use 'custom calculation script'.
EDIT: if any check box will checked it you can use this in all checkboxes as 'Mouse UP' event under 'actions' tab:
this.getField("Checkbox").checkThisBox(0,true);
Change "Checkbox" to your actual checkbox name.
Copy link to clipboard
Copied
Hi Nesa,
What action should I select after choosing Mouse Up. I thought it would be Add a Javascript, but I can't write anything in the Actions field.
Copy link to clipboard
Copied
Select 'Run a JavaScript' then click 'add' and paste script inside.
Copy link to clipboard
Copied
It worked! Thank you so much!!!
Now -if I uncheck it, how do I deactivate it o.0
Copy link to clipboard
Copied
Deactivate what exactly?
Copy link to clipboard
Copied
The Checkbox that was autochecked. How do I auto-uncheck it. 🙂
Copy link to clipboard
Copied
In that case use this script instead it will check/uncheck checkbox:
this.getField("Checkbox").checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
Awesome -thanks for everything!
Copy link to clipboard
Copied
Hi Nesa,
I am trying to make one Check Box check multilpe Check Boxes now.
I'm using the following variation of the script, and have tried multiple formats, but nothing seems to work:
this.getField("Check Box"+"Check Box2"+"Check Box3"+"Check Box4"+"Check Box5"+"Check Box6"+"Check Box7").checkThisBox(0,event.target.value == "Off" ? false : true);
Hope you can help again.
Thanks!
Copy link to clipboard
Copied
Rename your first checkbox from "Check Box" to "Check Box1" other checkboxes leave as they are and use this script:
for( var i=1; i<=7; i++)
this.getField("Check Box"+i).checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
I must have deleted the 1 at some point when I was playing with it.
This worked!
for( var i=1; i<=7; i++)
this.getField("Check Box"+i).checkThisBox(0,event.target.value == "Off" ? false : true);this.getField("Check Box1"+"Check Box2"+"Check Box3"+"Check Box4"+"Check Box5"+"Check Box6"+"Check Box7").checkThisBox(0,event.target.value == "Off" ? false : true);
Thank you so much!!!!
Copy link to clipboard
Copied
Remove the part with your code, use only the script I posted.
Copy link to clipboard
Copied
Sorry, one more question.
How do I alter this to add a non-sequenced Check Box.
for( var i=1; i<=7; i++)
I tried this:
for( var i=1; i<=7; i=99 i++)
this.getField("Check Box"+i).checkThisBox(0,event.target.value == "Off" ? false : true);this.getField("Check Box1"+"Check Box2"+"Check Box3"+"Check Box4"+"Check Box5"+"Check Box6"+"Check Box7"+"Check Box99").checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
If you are not gonna use sequenced field naming then I suggest use this and add more field names to variable 'fields' as you wish:
var fields = ["Check Box1","Check Box2","Check Box3","Check Box4","Check Box5","Check Box6","Check Box7","Check Box99"];
for(var i in fields)
this.getField(fields[i]).checkThisBox(0,event.target.value == "Off" ? false : true);
Copy link to clipboard
Copied
You are a saint -thank you!

