在yii2中选中复选后启用字段

时间:2016-04-05 11:52:42

标签: javascript php yii2

enter image description here

我已经附加了图像和代码。在此我想,在选中复选框启用该字段后它将被禁用。实际上我无法理解如何获取复选框的ID,因为在yii2和简单的HTML代码中它是不同的我我使用简单的html代码复选框和yii2格式的其他字段...谢谢你的进步

<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-inline" >
           <div class="row">
                <div class="col-lg-4">
                <input type="checkbox" id="Airshipment" name="Airshipment" value="A" selected>By Air
<!-- 
                <?=$form->field($modelAirshipment, 'air_ship_id')->checkBox(['label' => 'By Air', 'uncheck' => null, 'checked' => 'checked']); ?>
           -->
           </div>
           </div> 
            <div class="row">
                <div class="col-lg-4">
                    <?= $form->field($modelAirshipment, 'air_mawbno')->textInput(['maxlength' => true]) ?>

                </div>
                <div class="col-lg-4">
                    <?= $form->field($modelAirshipment, 'air_pieces')->textInput(['maxlength' => true]) ?>
                </div>
                <div class="col-lg-4">
                    <?= $form->field($modelAirshipment, 'air_packing_type')->dropDownList([ 'Box' => 'Box', 'Drum' => 'Drum', ], ['prompt' => '']) ?>
                </div>
            </div>
</div>
 <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 form-inline">
        <div class="row">
            <div class="col-lg-4">
            <input type="checkbox" id="Seashipment" name="Seashipment[S]" value="S" selected>By Sea
        </div>
        </div> 
        <div class="row">
            <div class="col-lg-4">
             <?= $form->field($modelSeashipment, 'sea_packing_type')->dropDownList([ 'Box' => 'Box', 'Drum' => 'Drum', ], ['prompt' => '']) ?> 
            </div>
            <div class="col-lg-4">
            <?= $form->field($modelSeashipment, 'sea_pieces')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-4">
             <?= $form->field($modelSeashipment, 'sea_dimension')->textInput() ?>
            </div>
        </div>
</div> 

1 个答案:

答案 0 :(得分:1)

之前我遇到过这个问题,我通过JS代码用hideshow元素解决它:)

window.onload中的

制作除复选框之外的所有元素.hide,选中后会生成所需的元素.show