Having problems populating a drop down menu using AJAX
I've built a php page that has the output of:
<option value="1">Item 1 | Item Name 1</option>
<option value="2">Item 2 | Item Name 2</option>
<option value="3">Item 3 | Item Name 3</option>
I can use ajax and populate a textfield no problem...
However on a list menu its not working...
I believe the problem is here:
document.getElementById(["groupitems"]).value = http_request.responseText;
I call the data by clicking an all button:
onclick="makeRequest('searchdata.php?pass=1')"
see the full AJAX below:
[begin example code]
<script type="text/javascript" language="javascript">
var http_request = false;
function makeRequest(url) {
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url, true);
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
alert(http_request.responseText);
document.getElementById(["groupitems"]).value = http_request.responseText;
} else {
alert('There was a problem with the request.');
}
}
}
</script>
[end example code]