User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,517 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,081 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1147 | Replies: 0
Reply
Join Date: Jan 2008
Posts: 10
Reputation: BillyMako is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
BillyMako BillyMako is offline Offline
Newbie Poster

Reload with drop-down and text fields

  #1  
Aug 7th, 2008
[IMG]http://i36.tinypic.com/11rus5g.jpg[/IMG]

So far i have a database with all data in it.
I have the 1st text field where the user enters their postcode and then the page reloads populating the drop down menu with the corresponding suburbs.

Next what i want is after a suburb has been selected in the list, the page reloads again and the corresponding city, state and country is displayed in the other 3 text fields.

How can i get the query to execute and fill in the last 3 fields after a suburb in the drop list has been selected???????

<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>

<title>Postcode and Address Selection Test</title>

<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.postcode.value;
self.location='dd.php?postcode=' + val ;
}

</script>
</head>

<body>
<?
@$postcode=$_GET['postcode']; // Use this line or below line if register_global is off
@$city=$_GET['city']; 
@$state=$_GET['state']; 
@$country=$_GET['country']; 
$city = 'not_complete';
$state = 'not_complete';
$country = 'not_complete';

/////// for suburb drop down list we will check if postcode is entered else we will display all the suburbs///// 
if(isset($postcode) and strlen($postcode) > 0){
$query=mysql_query("SELECT DISTINCT suburb FROM post2 where postcode=$postcode order by suburb"); //Table called POST2
}else{$query2=mysql_query("SELECT DISTINCT suburb FROM post order by suburb"); } 
////////// end of query for second subcategory drop down list box /////////////////////////////////////////////

echo "<form method=post name=f1 action='dd-check.php'>";//Goes to dd-check to check posted variables

//Page Reloads after 4 digits are entered///<<<<--------------POSTCODE FIELD-------<<<<<<<<<<<<<<
echo "Postcode: <input name='postcode' type=text onkeyup=\"if(this.value.length>3)reload(this.form);else return false;\" value=$postcode>";  
echo"<input value='Load Suburbs' type='button' onclick=\"reload(this.form)\" > Click to Load Suburbs for this Postcode.";

//////////////////Starting of suburb drop downlist///<<<<--------------SUBURB-------<<<<<<<<<<<<<
echo"<br><br>";
echo"Suburb: ";
echo "<select name='suburb'><option value=''>Select Suburb</option>"; // onchange=\"reload(this.form)\"
while($pop = mysql_fetch_array($query)) { 
echo  "<option value='$pop[suburb]'>$pop[suburb]</option>";
}//else{
//echo  "<option value='$pop[suburb]'>$pop[suburb]</option>";
//}
echo "</select>";
//////////////////  This will end the suburb drop down list ///////////

///////////////Execute this when suburb is selected////////////////////<<-----NEED TO FIX-------<<<<<<
//if(isset($suburb) and strlen($suburb) > 0){
$query_city=mysql_query("SELECT city FROM post2 where postcode=$postcode AND $suburb=$suburb");
//}else{
//$city = 'not_complete1';
//}
$query_state=mysql_query("SELECT state FROM post2 where postcode=$postcode AND $suburb=$suburb");
$query_country=mysql_query("SELECT country FROM post2 where postcode=$postcode AND $suburb=$suburb");

echo "<br>";
echo "<br>";
echo "City: <input name='city' type=text value=$city>";
echo "<br>";
echo "<br>";
echo "State: <input name='state' type=text value=$state>";
echo "<br>";
echo "<br>";
echo "Country: <input name='country' type=text value=$country>";

//-----------------------------------------------

echo "<br><br><input type=submit value=Submit>";
echo "</form>";
?>
</body>

</html>

Thankyou,
Billy
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC