SunQuest
 
      Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Tutorialized ForumsDesktop ProgrammingDelphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 14th, 2005, 04:19 PM
FirEwAteR FirEwAteR is offline
Junior Member
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 FirEwAteR New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
dynamically loading cities.

Hi, I'm looking to make a page that dynamically loads cities into an option field according to the country/state selected on the same page. All of the cities/states are stored in a mySQL database.

I would like to be able to use something like this:
Code:
function loadState(id) {
      var s;  
	  var stateName;
	  var cstate = new Array(); 
     
	 if(id==2){
			 <? //get states list from database
			$sqlState="select * from ae_states where country_id=2 order by state_name ASC";
			$reState=mysql_query($sqlState);
			$sct = mysql_num_rows($reState);
			
			$k=0;  
			while($rowState = mysql_fetch_array($reState)) {  ?>
			   s=<?=$k?>;
			   stateName='<? echo $rowState["state_name"]; ?>';
			   cstate[s]=stateName;
		    	<? $k=$k+1;
			} ?>

	 	    var len = cstate.length;
            cstate[len]="All states";
		    var field2 = document.frm_advSearch.asrch_state;
		    for(j=0; j<len+1; j++){
				newOpt=cstate[j];
				field2.length=j+1;
				field2.options[j]= new Option(newOpt,newOpt);
			} 
	 } 


But make the where clause dyncamically select using the id parsed from the country option input.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingDelphi > dynamically loading cities.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway