dimanche 12 juillet 2015

Get isset checkbox value on modal

I am sending values on modal using data-* for form editing. I am trying to send a checkbox value on this modal but it is not comparing its isset value to set whether the checkbox on the modal value will be checked or not checked.

Here's the button for edit/delete code:

<div class="btn-group">
    <a class="btn btn-primary" href="#"><i class="fa fa-female"></i> Yakult Lady</a>
    <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
    <span class="fa fa-caret-down"></span></a>
    <ul class="dropdown-menu">
        <?php
        echo "<li><a class=\"open-EditRow\" data-ylno=\"".$ylno."\" data-firstname=\"".$firstname."\" data-lastname=\"".$lastname."\" data-bday=\"".$bday."\" data-hired=\"".$hired."\" data-inactive=\"".$inactive."\" data-status=\"".$status."\" data-area=\"".$areano."\" title=\"Edit this row\" \"><i class=\"fa fa-pencil\"></i> Edit</a></li>";
        echo "<li><a class=\"open-DeleteRow\" data-ylno=\"".$ylno."\" data-firstname=\"".$firstname."\" data-lastname=\"".$lastname."\" title=\"Delete this row\" \"><i class=\"fa fa-trash\"></i> Delete</a></li>";
        ?>
    </ul>
</div>

Here's the edit modal code:

<div class="form-group">
    <label class="col-sm-3 control-label">Status</label>
    <div class="col-sm-5">
        <div class="checkbox">
            <label>
                <input type="hidden" name="status" id="status" value="<?php echo $status; ?>" />
                <input type="checkbox" onclick="enableStatus(this.checked, 'inactive1');" name="status" id="status"<?php if($status == "Inactive") { ?> checked="checked" <?php } ?>> Inactive
                <i class="fa fa-square-o small"></i>
            </label>
        </div>
    </div>
</div>

Here's its jquery code:

$('.open-EditRow').click(function(){
   var status = $(this).attr('data-status');
   $('#myModal #status').val(status);
   $('#myModal').modal('show');
});

How can I send the checkbox isset data to set the checkbox checked or unchecked?




Aucun commentaire:

Enregistrer un commentaire