单击复选框时禁用组合框

时间:2017-12-19 03:17:08

标签: javascript jquery html

我曾尝试禁用,但存在一些问题,首先,因为禁用而无法保存数据库。第二,当组合框具有来自其他javascript的 class = selected-select 时,禁用无效。我删除 class ='selected-select'时禁用,但无法保存数据库。这是代码。

//checkbox

<div class='side' style='top:4px'><input name='check' id='check' type='checkbox' class='regular-checkbox' onclick="run();" <?php if ($row['check']=="1"){echo "checked";} ?>/>&nbsp;
    <label for="check"></label>
</div>
<div class="labelbox"></div>

//combobox

<div class='side'>
    <select id="cmbobox" name="cmbobox" style="width:100px;"" class="chosen-select">
        <option value="">Kosong</option>
        <option value="3">3 Bulan</option>
        <option value="6">6 Bulan</option>
        <option value="9">9 Bulan</option>
        <option value="12>1 Tahun</option>
    </select>
</div>
<div class="labelbox"></div>

//javascript disabled combobox

<script type="text/javascript">
    jQuery.noConflict();
    function run(){
        var b = document.getElementById("cmbobox");
        if(document.getElementById("check").checked == true) 
        {
            b.disabled = true ;
        }
        else
        {
            b.disabled = false ;
        }
    }
</script>

//javacript chosen-select

<script type="text/javascript">
    jQuery.noConflict();
    var config = {
        '.chosen-select'           : {},
        '.chosen-select-deselect'  : {allow_single_deselect:true},
        '.chosen-select-no-single' : {disable_search_threshold:10},
        '.chosen-select-no-results': {no_results_text:'Data tidak ketemu'},
        '.chosen-select-width'     : {width:"95%"}
    }
    for (var selector in config) {
        jQuery(selector).chosen(config[selector]);
    }
</script>

0 个答案:

没有答案