mercredi 20 avril 2016

Change select option with checkbox checked and jQuery

I have a form (with Contact Form 7 on Wordpress). This form has a feature for display a <div> when a checkbox is checked (with jQuery). I wish also that when this checkbox is checked, the select > option change this value.

eg: if the checkbox is not checked, the select > option has value "NORMAL", but if checkbox is checked, the select > option has value "EXPORT".

My Form (HTML, not Contact Form 7)

<form action="" method="post" class="wpcf7-form">
    <!-- Inputs -->
    <input name="chkCheckbox" type="checkbox" id="checkbox" class="checkboxMail" />Export Demand
    <div class="checkMailOK">
            <!-- Others inputs -->
    </div>
    <select name="mail" class="wpcf7-form-control wpcf7-select mail" id="mail">
        <option value="NORMAL">NORMAL</option>
        <option value="EXPORT">EXPORT</option>
    </select>
    <!-- Others inputs -->
</form>

My JS

$(document).ready(function() {

    $(".checkboxMail").click(function() {

        $(".checkMailOK").slideToggle(400);

    });

});

Thank you in advance for your response.




Aucun commentaire:

Enregistrer un commentaire