mercredi 2 janvier 2019

when checkbox checked then radio button is unchecked and when checkbox unchecked then radio button is checked using jquery

I have a form there contains one checkbox and one radio button. I am doing that when checkbox checked then radio button is unchecked and when checkbox unchecked then radio button is checked using jquery

<form class="col s12" action="rpt_collection_summary.php" method="post" enctype="multipart/form-data" name="frm1" target="_blank">
    <input type="radio" id="test5" checked="checked" name="thismonth" value="<?php echo date("Y-m");?>"/>
    <input type="checkbox" id="chk_date" name="chk_date" value="1" /><label for="chk_date">Select Date </label>
</form>

Issue is that when checkbox is unchecked then radio is not checked. I am doing like this way

<script>
$(document).ready( function() {
$('#chk_date').click( function() {
    var value = $('#chk_date').val();
    if(value != '') {
        $('[name="frm1"] input:radio').removeAttr('checked');
    } else {
        $('#test5').Attr('checked');
    }

});
});
</script>




Aucun commentaire:

Enregistrer un commentaire