Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
freeword
New Member
New Member



Joined: May 08, 2007
Posts: 2

PostPosted: Tue May 08, 2007 10:48 am Reply with quote

I am trying to make submission form. Right now, there are 43000 cities. Too many. The cities are the children of the states.

I want a user to select THE STATE - then have the second pulldown generate the cities for that state only.

This stupid {form:category_list} is the back-end command for the pulldown.

The cities are in the db according to parent id number. PID.

$category_list = "";
$rrr = $row->cid ? $row->cid : "";
$this->html = str_replace("{form:category_list}", buildcatList($rrr), $this->html);
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Wed May 09, 2007 6:34 am Reply with quote

freeword, two possible methods come to mind:

1. Where all the data is passed back to the browser and then via javascript and manipulation of the DOM, as the user changes the state form field, you trigger a javascript function which adusts the options that are listed in the city form field.

2. Using AJAX to dynamically query the database each time the state form field changes and then manipulate the city form field options.

Either way, you are going to have to get your hands real dirty and detailed into the coding. There is no easy way if you are wanting to avoid having to go back to the server and repaint the web page each and every time.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
freeword







PostPosted: Wed May 09, 2007 6:37 am Reply with quote

Montego- My buddy and I will try the javascript tonight - let you know how it goes - the AJAX is beyond me still...
 
montego







PostPosted: Wed May 09, 2007 7:08 am Reply with quote

Personally, I would do something like load up the cities into an array using the state's PID as the key... then, when the onchange event is triggered in the state field, have the javascript set the city option values/text to the right ones.

Of course, with everything, there is probably 10 different ways of doing it. Even in what I've described above, there are still multiple variations on how to actually accomplish it.

Good luck!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©