2

I have this code:

<div class="form-group">
                        <?= $form->labelEx($model, 'd_options', array('class' => 'col-xs-12 col-sm-4 control-label')) ?>
                        <div class="col-xs-12 col-sm-8" id="d_options_element">
                            <?= $form->checkBoxList($model, 'd_options', $model->getData('d_options'), array(
                                'template' => '<div  class="checkbox col-xs-12 col-sm-4">{beginLabel}{input}{label}{endLabel}</div>',
                                'separator' => '',
                            )); ?>
                            <div class="col-xs-12 col-sm-8 p_16_13" id="d-parts"
                                 style="<?= (in_array(12, $model->d_options)) ? '' : 'display: none;' ?>">
                                <?= $form->textField($model, 'p_16_13', array(
                                    'class' => 'form-control dotted', 'placeholder' => Yii::t('subscription', 'указать другой вид деятельностит'))) ?>
                                <?= $form->error($model, 'p_16_13') ?>
                            </div>
                            <?= $form->error($model, 'p_16') ?>
                        </div>
                    </div>

getData retrieve elements of checkbox: this code is getData code:

 $data = array(
            'b_category' => array(
               '1', 
               '2',
               '3',
               'other'   
                      ),
);
        return $data[$property];
    }

I could not develop js file that responsible for showing/hiding following textField:

<?= $form->textField($model, 'p_16_13', array(
                                    'class' => 'form-control dotted', 'placeholder' => Yii::t('subscription', 'указать другой вид деятельностит'))) ?>

only when user presses 'other' button.(getData array). How can i develop it?

phpdev
  • 511
  • 4
  • 22

1 Answers1

0
$(selector).on('change', function(){
    if($(this).is(':checked')){
        // checkbox is checked
    } else {
        // here is not
    }
});
michail_w
  • 4,318
  • 4
  • 26
  • 43