Dropdownlist and Checkbox field triggering a javascript function

Asked

Viewed 25 times

0

I have two Dropdownlist and Checkbox fields that are responsible for entering value into an inputtext

How to make javascript code know the status sent true or false from the CHECKBOX to the function.

Dropdownlist

<div class="col-md-10">
     @Html.DropDownList("PlanoId", null, htmlAttributes: new { @class = "form-control" })
</div>

Checkbox

<div class="checkbox">
      @Html.EditorFor(model => model.AnuncioDestaque)
</div>

How to Dropdownlist Checkbox Above, Trigger Javascript Below

$(document).ready(function () {
    $("#PlanoId, #AnuncioDestaque").on("change focusout", function () {

           //Pegar Status do Checkbox se vei true ou false
    });

});

1 answer

2

Without jQuery

document.getElementById('PlanoId').checked;

With jQuery

$('#PlanoId').is(':checked');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.