web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get CheckBox value on change in Microsoft custom Portals?

(0) ShareShare
ReportReport
Posted on by 152

Hello everyone,

I just get recently started with Microsoft custom Portals and I am trying to hide or display labels and fields based on a checkbox value.

I followed this approach :

https://dynamicsofdynamicscrm.com/2017/08/22/dynamics-365-portal-code-tip-dynamically-showhide-field-based-on-another-field-on-entity-form/

and i think i am almost there, but i am not getting the checkbox value correctly.

This is my code:

$(document).ready(function () {
alert("hello");
$("#venvn_departmenta").change(onReasonChange);
$("#venvn_departmenta").change();
});

function onReasonChange(){
alert("On Reason Change called");
alert("checkbox value a = "+$('#venvn_departmenta').val());
alert("checkbox value b = "+$('#venvn_departmentb').val());
if ($('#venvn_departmenta').val() == true)
{
$('#venvn_qa_areyouamanager_label').show();
$('#venvn_qa_areyouamanager').show();
$('#venvn_qa_activeregionalambulancefacility_label').show();
$('#venvn_qa_activeregionalambulancefacility').show();
}
else
{

alert("checkbox value a = "+$('#venvn_departmenta').val());
alert("checkbox value b = "+$('#venvn_departmentb').val());
$('#venvn_qa_areyouamanager_label').hide();
$('#venvn_qa_areyouamanager').hide();
$('#venvn_qa_activeregionalambulancefacility_label').hide();
$('#venvn_qa_activeregionalambulancefacility').hide();
}
}

At the moment, the script get triggered every time i modify the checkbox venvn_deparmenta, but does not matter if the checkboxes deparmenta and deparmentb are checked or unchecked, I always execute the  hidding state and i alert always value = on (checkbox checked value = on, checkbox unchecked value = on too)

does someone know which condition should i analyze to check if the checkbox is checked or not?

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Jorge Gomez Profile Picture
    152 on at

    does anyone have experience about it?

  • Verified answer
    Jorge Gomez Profile Picture
    152 on at

    Okay I found the solution by myself, in case someone needs it in a future

    var isCheckBoxAChecked=$("#checkboxId").is(":checked");

    is a boolean variable, its value is true if is checked, and false if its unchecked.

    $(document).ready(function () {

    $("#checkboxId").change(onReasonChange);

    $("#checkboxId").change();

    });

    function onReasonChange(){

    var isCheckBoxAChecked=$("#checkboxId").is(":checked");

    if (isCheckBoxAChecked == true)

    {

    // your own logic

    }

    else if(isCheckBoxAChecked == false)

    {

    //your own logic

    }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans