0

here is the reference link, http://talkerscode.com/webtricks/dynamic-select-option-menu-using-ajax-and-php.php which helped me to get dynamic select option, but it has to be modified to get selected option to display other column values from data base, here is what i got

 function fetch_select(val)
    {
       $.ajax({
         type: 'post',
         url: 'fetch_data.php',
         data: {
           get_option:val
         },
         success: function (response) {
           document.getElementById("new_select").innerHTML=response; 
         }
       });
    }

what i want to do is, add miltiple id's to fetch data from database, like..

 function fetch_select(val)
    {
       $.ajax({
         type: 'post',
         url: 'fetch_data1.php',
         data: {
           get_option1:val
         },
         success: function (response) {
           document.getElementById("new_select1").innerHTML=response; 
         }
       });
    } 

and

 function fetch_select(val)
    {
       $.ajax({
         type: 'post',
         url: 'fetch_data2.php',
         data: {
           get_option2:val
         },
         success: function (response) {
           document.getElementById("new_select2").innerHTML=response; 
         }
       });
    }

please refer to the demo link : DEMO

Thanks for the Response .......

ArK
  • 20,698
  • 67
  • 109
  • 136

2 Answers2

0

You need to get first select option value to do that

var state = $("select#state option:selected").attr('value');

$.post('file.php', {state:state}, function(data) {

// do stuff
});
jack brone
  • 205
  • 5
  • 24
0

Can I get the (id of input) (without submitting the form) through PHP, so i can check the select query to match the id....

<input type="text" id="new_select" >

document.getElementById("new_select").innerHTML=response;

Thanks!