Can someone take a look at my site I am beginning to create and tell me why my drop downs for state and cities are not working? The state drop down box gets pre loaded which works fine but when you select the state it will refresh the screen and populate the cities (this works but what happens is that only the city shows up on my site and not the other content. Go to: [url]www.garagesalelister.com
Here is some of the code:
[code=php]
<body class=”thrColFixHdr”>
<?php
include “dbconnect.php”;
?>
<div id=”container”>
<div id=”header”>
<center>
<IMG SRC=”garagesalelister.jpg”>
</center>
<!– end #header –></div>
<div id=”sidebar1″>
<h8>Find Garage Sales in your area</h8>
<br /><br />
<script type=”text/javascript”>
function createRequestObject() {
var req;
if(window.XMLHttpRequest){
// Firefox, Safari, Opera…
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
// Internet Explorer 5+
req = new ActiveXObject(“Microsoft.XMLHTTP”);
} else {
// There is an error creating the object,
// just as an old browser is being used.
alert(‘Problem creating the XMLHttpRequest object’);
}
return req;
}
// Make the XMLHttpRequest object
var http = createRequestObject();
function sendRequest(id) {
// Open PHP script for requests
http.open(‘get’, ‘getcities.php?id=’+id);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4 && http.status == 200){
// Text returned FROM the PHP script
var response = http.responseText;
if(response) {
// UPDATE ajaxTest content
document.getElementById(“container”).innerHTML = response;
}
}
}
</script>
<?php
//connect to database
$sql = “SELECT `id`,`state` FROM `states`”;//select all our states
$result = mysql_query($sql) or die(mysql_error());
echo ‘<select name=”state” onChange=”sendRequest(this.value)”>’;//the select box with the javascript function to change the cities
echo ‘<option value=”none”>Please select a state</option>’;
while(list($id,$state) = mysql_fetch_row($result)){
echo ‘<option value=”‘.$id.'”‘.’>’.$state.'</option>’;
}
echo ‘</select>’;
?>
Thanks in advance,
Scott