Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Making One Check Box Check Another

Explorer ,
Feb 07, 2022 Feb 07, 2022

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

TOPICS
JavaScript
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
4 ACCEPTED SOLUTIONS
Community Expert ,
Feb 07, 2022 Feb 07, 2022

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

Select 'Run a JavaScript'  then click 'add' and paste script inside.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

In that case use this script instead it will check/uncheck checkbox:

this.getField("Checkbox").checkThisBox(0,event.target.value == "Off" ? false : true);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

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);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2022 Feb 07, 2022

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.

 

MBLogic_0-1644271935441.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

Select 'Run a JavaScript'  then click 'add' and paste script inside.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2022 Feb 07, 2022

It worked! Thank you so much!!!

Now -if I uncheck it, how do I deactivate it o.0

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

Deactivate what exactly?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2022 Feb 07, 2022

The Checkbox that was autochecked. How do I auto-uncheck it. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2022 Feb 07, 2022

In that case use this script instead it will check/uncheck checkbox:

this.getField("Checkbox").checkThisBox(0,event.target.value == "Off" ? false : true);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2022 Feb 07, 2022

Awesome -thanks for everything!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022

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!

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022

 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!!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

Remove the part with your code, use only the script I posted.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022

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);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022
LATEST

You are a saint -thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines