How to change toggle switch through database

Asked

Viewed 64 times

1

I am trying to change the bool in the database to true or false, the toggle switch to change, depending on true or false.

<script>
$(document).ready(function () {
    for (var i = 0; i < '@Model.Participantes.Count()'; i++) {
        if ($('#Participantes_' + i + '__ID').val() == "true")
            $(".botaoConfirmacao[data-rowindex='" + i + "']").prop('checked', true).change();
        else
            $(".botaoConfirmacao[data-rowindex='" + i + "']").prop('checked', false).change();
        i++;
    }

    $('.botaoConfirmacao').change(function (event) {
        event.preventDefault();
        if ($(this).prop('checked')) {
            $('#' + $(this).attr('id')).val('true');
        }
        else {
            $('#' + $(this).attr('id')).val('false');
        }
    });
 });

  • Using which plugin? Jquery Toggle switch? https://plugins.jquery.com/toggleswitch/ ?

  • No, bootstrap toggle switch

No answers

Browser other questions tagged

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