step 1: add a line
// Your code //just call another function to get db driven combo. get_education_combo();
Step 2: write the following javascript function to extract the result from php code and send to the html element.
function get_education_combo() { var url ="print_education_list"; //alert(url); var contents = AjaxRequest(url); //alert(contents); //return contents; //send the result to html document.getElementById("elementID").innerHTML=contents; } function AjaxRequest(url) { //alert(url); if(xmlhttp != null){ if(xmlhttp.abort) xmlhttp.abort(); xmlhttp = null; }; if(window.XMLHttpRequest) // good browsers xmlhttp=new XMLHttpRequest(); else if(window.ActiveXObject) // IE xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if(xmlhttp == null) return null; xmlhttp.open("GET",url,false); xmlhttp.send(null); // alert(xmlhttp.status); if(xmlhttp.status >= 200 && xmlhttp.status < 300)// 2xx is good enough return xmlhttp.responseText; else return null; }
Step 3: PHP Code
print_education_list() { $education="your query"; echo '<select name="edu_name" id="edu_name" style="width:70px;">'; foreach($education as $edu) { echo '<option>'; echo $edu->sEducationName; echo '</option>'; } echo '</select>'; }
It. GOOD LUCK. I prepared this combination while developing DeskTop application on php.
source share