Jump to content
  • 0

Hiding a checkbox unless another checkbox is checked


pmyersjr

Question

I am trying to only show a checkbox if another checkbox is checked. After that I want an input field to appear if the 2nd checkbox is checked, but one thing at a time. I cannot figure it out. Basically, If someone checks the "Purchase_Question" box, I want the "Try_On_Question checkbox to appear. Can anyone help me please?? I can't figure it out. Here is my code:

var o_checkbox = document.getElementById("Purchase_Question");

var o_co_app_firstname=document.getElementById("Try_On_Question");

if(o_checkbox.checked)

{

o_co_app_firstname.style.display = '' ;

}

else

{

o_co_app_firstname.style.display ='none';

}

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi,

If this is a web form, you should reference fields as InsertRecordFIELDNAME, if an Update or Details page then reference as EditRecordFIELDNAME:

var o_checkbox = document.getElementById("InsertRecordPurchase_Question");

var o_co_app_firstname=document.getElementById("InsertRecordTry_On_Question");

if(o_checkbox.checked)

{

o_co_app_firstname.style.display = 'block' ;

}

else

{

o_co_app_firstname.style.display ='none';

}

Link to comment
Share on other sites

  • 0

Hi @pmyersjr,

 

To add from the previous comments above, you can use conditional forms to achieve that. You need to create a rule that when the first checkbox is unchecked hide other fields. 

Please refer to this screenshot:

image.png.28f03c816e9f3ff066ef508ee0636e93.png

 

image.png.2297e04fbe71807a7a8443639a9cfa54.png                            

image.png.dd1f2ffc9e9b3ec931be067d6740f1b7.png     

 

For more information about the conditional forms, you can go through this article:  https://howto.caspio.com/datapages/forms/conditional-forms/

 

Regards,

kristina

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...