/    Sign up×
Community /Pin to ProfileBookmark

3 listbox ajax dropdown with reload(this.form)

what i am trying to do is have 3 listbox that reload as you click them

here is the js

[CODE]
function reload(form)
{
var val=form.state.options[form.state.options.selectedIndex].value;
self.location=’homes.php?state=’ + val;
}
function reload1(form)
{
var val=form.state.options[form.state.options.selectedIndex].value;
var val2=form.county.options[form.county.options.selectedIndex].value;
self.location=’homes.php?state=’ + val + ‘&county=’ + val2;
}
function reload2(form)
{
var val=form.state.options[form.statet.options.selectedIndex].value;
var val2=form.county.options[form.county.options.selectedIndex].value;
var val3=form.city.options[form.city.options.selectedIndex].value;
self.location=’homes.php?state=’ + val + ‘&county=’ + val2 + ‘&city=’ + val3;
}
[/CODE]

here is the html

[code=php]
<?
include’admin/configs/configs.php’;
@$state=$_REQUEST[‘state’];
@$county=$_REQUEST[‘county’];
@$city=$_REQUEST[‘city’];

$quer2=mysql_query(“SELECT DISTINCT state,id FROM states”);

if($state){
$quer=mysql_query(“SELECT DISTINCT * FROM county where state=’$state'”); }

$quer3=mysql_query(“SELECT DISTINCT * FROM cities where county=’$county'”);

echo “<form method=post name=f1 action=’homes.php?state=$state&county=$county’>”;

echo “<select name=’state’ onchange=”reload(this.form)”><option value=”>Select one</option>”;
while($mbfh2 = mysql_fetch_array($quer2)) {
if($mbfh2[‘state’]==@$state){echo “<option selected value=’$mbfh2[state]’>$mbfh2[state]</option>”.”<BR>”;}
else{echo “<option value=’$mbfh2[state]’>$mbfh2[state]</option>”;}
}
echo “</select>”;

echo “<select name=’county’ onchange=”reload1(this.form)”><option value=”>Select one</option>”;
while($mbfh = mysql_fetch_array($quer)) {
if($mbfh[‘county’]==@$county){echo “<option selected value=’$mbfh[county]’>$mbfh[county]</option>”.”<BR>”;}
else{echo “<option value=’$mbfh[county]’>$mbfh[county]</option>”;}
}
echo “</select>”;

echo “<select name=’city’ onchange=”reload2(this.form)”><option value=”>Select one</option>”;
while($mbfh3 = mysql_fetch_array($quer3)) {
if($mbfh3[‘city’]==@$city){echo “<option selected value=’$mbfh3[city]’>$mbfh3[city]</option>”.”<BR>”;}
else{echo “<option value=’$mbfh3[city]’>$mbfh3[city]</option>”;}
}
echo “</select>”;

echo “<input type=submit value=Submit>”;
echo “</form>”;

?>

[/code]

the first 2 buttons reload the last one does not reload
i need the last one to reload please thankz

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cabalsdemonJun 09.2012 — i meant the first 2 dropdowns reload the last one does not reload

i need the last one to reload please thankz
Copy linkTweet thisAlerts:
@cabalsdemonJun 13.2012 — nm i found what i did wrong had xtra t in state

var val=form.state.options[form.state[B]t[/B].options.selectedIndex].value;[/QUOTE]
×

Success!

Help @cabal 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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