dimanche 5 mars 2017

Checkbox Hidden Div Unchecked

I have a checkbox hidden div with text field. If checkbox is checked this text field will showed, but if checkbox unchecked text field not show. This Code :

<script type="text/javascript">
    $(function () {

        $("input[name='checkbox1']").click(function () {

            if ($("#checkyes1").is(":checked")) {
                $("#dvcheckbox1").show('lainnya');

            } else {

                $("#dvcheckbox1").hide('lainnya');
            }



        });
    });
</script>

<div style="margin-left: 29%; margin-top: -2%;">
<label for="checkyes1">

<input type="checkbox" id="checkyes1" name="checkbox1" value="lainnya" />
Lainnya
</label>

<div id="dvcheckbox1" style="display: none;">
    <?php echo $form->textField($model,'lainnya'); ?>
</div>
</div>

But, How this checkbox is checked if there something value on textfield? and text field shown.

For example Like this: Click to show example




Aucun commentaire:

Enregistrer un commentaire