Skip to main content
Participant
January 13, 2022
Answered

Disable Checkbox with same name as another but different export value based on another checkbox

  • January 13, 2022
  • 1 reply
  • 703 views

I have searched this forum literally for hours to find help with this.

I have four checkboxes: Cancer (export value is Yes), Cancer (export value is No), ICU (export value is Yes), and ICU (export value is No).

Users should not be able to check both Yes and No for either Cancer or ICU. So, I'm good here.

However, users also cannot select Cancer (export value No) and ICU (export value Yes). Therein lies my issue.

How can I disable ICU (export value Yes) only when Cancer (export value No) is checked and simultaneously check ICU (export value No)?

I am not even a rookie to javascript - far less 😂. However, I'm a wiz at copying and pasting. Help!

This topic has been closed for replies.
Correct answer Nesa Nurani

In checkbox "Cancer" with "No" export value under 'Action' tab, as 'Mouse UP' event select 'Run a JavaScript' and paste this script:

if(event.target.value == "No"){
this.getField("ICU").value = "No";
this.getField("ICU").readonly = true;}

Same process as above but this time for  "Cancer" with "Yes" export value use this:

this.getField("ICU").readonly = false;
this.getField("ICU").value = "Off";

You don't need last line to set "ICU" to off if you don't wan't, it's just to clear "ICU" if you first selected "No" then changed mind and selected yes, so you decide if you want it or not.

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
January 13, 2022

In checkbox "Cancer" with "No" export value under 'Action' tab, as 'Mouse UP' event select 'Run a JavaScript' and paste this script:

if(event.target.value == "No"){
this.getField("ICU").value = "No";
this.getField("ICU").readonly = true;}

Same process as above but this time for  "Cancer" with "Yes" export value use this:

this.getField("ICU").readonly = false;
this.getField("ICU").value = "Off";

You don't need last line to set "ICU" to off if you don't wan't, it's just to clear "ICU" if you first selected "No" then changed mind and selected yes, so you decide if you want it or not.

Participant
January 13, 2022

This works perfectly. Thank you, Nesa!