Re: Dynamic dropdown lists (select)

From: Date: Fri, 04 Apr 2008 20:30:36 +0000
Subject: Re: Dynamic dropdown lists (select)
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-272554@lists.php.net to get a copy of this message
On Fri, Apr 4, 2008 at 2:19 PM, Nitsan Bin-Nun <nitsanbn@gmail.com> wrote: > After reading the rest of the conversation, I think the best solution is > the next thing: > First, if I got this correct, you can extract the makes select-element > from the mysql using a query? if so, then extract it and host is in a temp > variable. > The next thing is writing down a js code, that contains an array of models > for each make. Personally, I'd use a 2 dimension array, the first dimension > for the make id/name and the second for the model id/name. > The 2 dimm. array you write with something like > > > > echo '<script type="text/javascript">var whatever = new > > Array();'; > > foreach ($cars as $idx => $car) > > echo 'whatever['.$idx.'] = > > "'.$car->getName().'";'; > > echo '</script>'; > > > as Zoltan said. > Then you have just simplefied it to a JS based script, i think this is the > best way you will figure out which does NOT contains AJAX, only static JS ;) > you have to be careful with this approach. sending too much data to the client can kill performance; im guessing this is even more sensitive in the context of mobile client. just use careful judgement (and testing ! ;)) ; if there are a couple dozen entries total, probly this route is acceptable. if there are several hundred.... -nathan

« previous php.general (#272554) next »