javascript - two dropdowns on one dependent dropdown codeigniter -


i have dependent dropdown function have dropdown , 1 depending on it,

here html

            <select class="form-control" name = "prov_id" id = "prov_id">               <option></option>                 <?php foreach ($content2 $cs) {?>                   <option value="<?php echo $cs->prov_id; ?>"><?php echo $cs->province; ?></option>                 <?php } ?>              </select>                <select class="form-control" name = 'ct_id' id = 'ct_id'>                   <option value=""></option>               </select> 

and here javascript

jquery(document).ready(function(){   $("#prov_id").change(function() {     var provid = {"provid" : $('#prov_id').val()};     console.log(provid);      $.ajax({       type: "post",       data: provid,       url: "<?php base_url(); ?>employees/dependent_dropdown/",        success: function(data){           var select = $('#ct_id');           select.html('');           $.each(data, function(i, option){               select.append("<option value='"+option.ct_id+"'>"+option.city+"</option>");           });       }      });    });  }); 

now want have 1 this, wanted have selected values first 2 dropdowns before dependent 1 shows values.

e.g.

first dropdown -->select value second dropdown -->selects value

dependent dropdown --> gives values according first , second dropdown.

example: select * thistable column1 = 'firstdropdownvalue' , column2 = 'seconddropdownvalue'

then dropdown values result.

jquery(document).ready(function(){   $("#ct_id").change(function() {     var provid_two = {"provid" : $('#prov_id').val(), "ct_id" : $('#ct_id').val()};     console.log(provid);      $.ajax({       type: "post",       data: provid_two,       url: "<?php base_url(); ?>employees/dependent_dropdown2/",        success: function(data){           var select = $('#provid_two');           select.html('');           $.each(data, function(i, option){               select.append("<option value='"+option.ct_idnew+"'>"+option.citynew+"</option>");           });       }      });    });  }); 

you can try this. pass 2 selected values. hope understood


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -