首页 > 解决方案 > 我将如何进行如果大学是检查然后这门课程将在下拉列表中?

问题描述

So I am trying to do an that If the College is selected in the checkbox then the college course would show like 

BS-IT, BS-IT-DA, BS-CS 在下拉列表中,否则如果高级选中,则链将显示 GAS、IT、CS。我不知道 JavaScript 或 J-Query 是否需要它

<div class="form-group right">
     <label class="label-title">Status</label>
     <div>
         <label><input type="checkbox">College Student</label>
         <label><input type="checkbox" class="senior-high" >Senior High</label>
     </div>
</div>

<div class="horizontal-group">
     <div class="form-group left">
          <label for="">Course</label>
          <select  id="Course"></select>
     </div>
</div>

标签: javascripthtml

解决方案


//首先在拼贴复选框上添加 id="collage" 并在所有复选框上添加 class="checkbox" 在高级 hs 复选框上添加 Senior_highcheckbox id

$(document).on('click','.checkbox'function(){
 if($('#college').is('checked')){
    $('#course').append(`<option>BS-IT </option> 
                        <option>BS-IT-DA</option>
                        <option>BS-CS</option>`);
    $('#senior_highcheckbox').attr('checked',false);
 }else{
   $('#course').append(`<option>GAS</option>
                       <option>IT</option>
                        <option>CS</option>`);
   $('#college').attr('checked',false);
 }
})

推荐阅读