lundi 6 novembre 2017

Jquery prop does not sends checkbox value to form action

I used prop to force check second checkbox when firts check box is checked:

my html:

<input name="first" id="first" value="yes">first
<br>
<input name="second" id="second" value="yes">second
<br>

my script:

$(document).ready(function(){
    $("#first").change(function(){
        if (this.checked){
            $("#second").prop('checked', true).attr("disabled","disabled");
        } else {
            $("#second").prop('checked', false).removeAttr("disabled");
        }
    });
});

In target page, I don't receive value of yes from second checkbox when it is checked using prop but I receive it when I really click it to check. Do I need something more than prop?




Aucun commentaire:

Enregistrer un commentaire