I am having 2 dropdowns what I want is to get values from database when I select any value from 1st drop down the 2nd drop Down should change values and gets populated from database according to the value selected in 1st dropdown..It a one table one only and I am using JavaScript and I know that I need to use ajax but have no idea how should I connect to database through that..
<label> List of Tables : </label><br>
<form name="myform" id="myForm">
<select name="optone" id="jobSelect" size="1">
<option value="" selected="selected">Select job</option>
</select>
<br>
<br>
<select name="opttwo" id="attrSelect" size="1">
<option value="" selected="selected">Select attribute</option>
</select>
</form>
<script> // AJAX Implementation
function showJobs() {
str = document.getElementById("jobs").value;
str1 = document.getElementById("attributes").value;
if (str == "" || str1 == "") {
document.getElementById("txtHint").innerHTML = "";
return;
}
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "WHAT TO MENTION HERE + str + "&q=" + str1, true);
xmlhttp.send();
}
</script>
PLEASE SUGGEST SOMETHING!!!!!