Top Ad unit 728 × 90

Set combobox value using jquery | Populate dropdown list box

To change the value of the combobox based on the selection in the drop down, this should do the trick:
$("#combobox").change(function() {
    var curVal=$(this).val();
There needed to be a function to handle the change of the combobox select field. On change it will run the combobox function with the autocomplete value of the currently selected option in #combobox.

Let's take another example to populate listbox2 on change event of listbox1 using ajax post:

Following code will be written in jquery or java script file. Assume that you have two list box in your html form

          $("#listbox1").on("change", function(event){
                var listbox1_code = $("#listbox1").select2().select2("val");  

                $.post("url_path/get_list.php?code="+listbox_code_1, function(data) { 
                         if(a_sub_type == ''){
//to clear listbox2
                                  $("#listbox2").select2().select2("val", '');
//show empty text i.e. 'Select One'
//for refresh listbox...
                         } else {
                                  $("#listbox2").select2().select2("val", 'Select One');
//for refresh list...
//end of else if part...
//end of ajax post....

          }); //end of listbox_1 change event...
//end of document ready event...

If you have any query regarding this please let me know.
Set combobox value using jquery | Populate dropdown list box Reviewed by Ashok Sen on 00:43:00 Rating: 5

No comments:

Website Design Company at Kolkata All Rights Reserved © 2014 - 2019
Developed by Asenwebmedia

Contact Form


Email *

Message *

Powered by Blogger.