mercredi 25 mai 2016

Conditional checkbox and active field

i'm create a plugin and i've add some field. I need to make active this custom field only user select a checkbox.

I do this

<?php
echo '<input type="checkbox" name="mycheckbox" id="mycheckbox" value="0" />';
echo '<div id="mycheckboxdiv" style="display:none">';

              woocommerce_wp_text_input( array( 'id' => "_bulkdiscount_quantity_$i", 'label' => __( 'Quantity (min.)', 'wc_bulk_discount' ), 'type' => 'number', 'description' => __( 'Enter the minimal quantity below apply the discount', 'wc_bulk_discount' ), 'custom_attributes' => array(
                                'step' => '1',
                                'min' => '1'
                            ) ) );
                            woocommerce_wp_text_input( array( 'id' => "_bulkdiscount_discount_$i", 'type' => 'number', 'label' => __( 'Discount (%)', 'wc_bulk_discount' ), 'description' => __( 'Enter the discount in percents', 'wc_bulk_discount' ), 'custom_attributes' => array(
                                    'step' => 'any',
                                    'min' => '0',
                                    'max' => '100'
                                ) ) );
              echo '</div>';

?>

<script type="text/javascript">


$(document).ready(function() {
    $('#mycheckbox').change(function() {
        $('#mycheckboxdiv').toggle();
    });
});

</script>

But if i select checkbox my field not appear. Where i wrong?

Thanks




Aucun commentaire:

Enregistrer un commentaire