/    Sign up×
Community /Pin to ProfileBookmark

Problems with my drop down menus

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[/url] and then select a state and see what happens.

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>’;
?>
[/code]

Thanks in advance,

Scott

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scarlsonauthorNov 27.2007 — Should I post this somewhere else? I would have thought I would have had a possible answer by now. Let me know if I should move this to another forum area.

Thanks,

Scott
×

Success!

Help @scarlson spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...