Connecting Tech Pros Worldwide Forums | Help | Site Map

dynamic dropdown box

adam
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi - im looking to have two drop down boxs one with makes of car and
the second drop down box to automatically populate with all the model
of that particular make of car. there are about 50 makes and upto 50
models per make.

I just would like to know the best way to do this - javascript or use
a database? it would be a lot of code todo it in javascript wouldnt
it?? help is very much appreciated thanks guys.

Ginzo
Guest
 
Posts: n/a
#2: Jul 17 '05

re: dynamic dropdown box


The answer depends on a few things:

1) Whether or not you are willing to issue a new page request in order
to populate the second list.

2) How much data do you have.

With JavaScript, you'll basically need to download the whole dataset
to the client - which is probably not fair and may even cause a crash
on less well equipped systems, whereas a quick request back to the
server would be pretty breezy by comparison.

OTOH, if you your data set is fairly small (try exporting everything
to a CSV and see what the KB weight is (<120 is a good target); then
JavaScript probably is worth the effort just to avoid an ugly page
refresh.

It is a myth that JavaScript is significantly more difficult than PHP.
A little obtuse, perhaps, but it would be a short leap. There is an
abundance of script templates that do exactly what you describe. I
particularly like hotscripts.com as a resource for this.

Good Luck

On 30 Nov 2004 14:16:21 -0800, adamnichols45@hotmail.com (adam) wrote:
[color=blue]
>Hi - im looking to have two drop down boxs one with makes of car and
>the second drop down box to automatically populate with all the model
>of that particular make of car. there are about 50 makes and upto 50
>models per make.
>
>I just would like to know the best way to do this - javascript or use
>a database? it would be a lot of code todo it in javascript wouldnt
>it?? help is very much appreciated thanks guys.[/color]


Ciao,


Ginzo
---------------------------------
War is god's way of teaching
Americans geography
-- Ambrose Bierce
---------------------------------
Jerry Gitomer
Guest
 
Posts: n/a
#3: Jul 17 '05

re: dynamic dropdown box


adam wrote:
[color=blue]
> Hi - im looking to have two drop down boxs one with makes of
> car and the second drop down box to automatically populate
> with all the model of that particular make of car. there are
> about 50 makes and upto 50 models per make.
>
> I just would like to know the best way to do this - javascript
> or use
> a database? it would be a lot of code todo it in javascript
> wouldnt it?? help is very much appreciated thanks guys.[/color]

Unless you enjoy spending a lot of time modifying programs you
should use a database.

By the way, unless you are only dealing with one model year at a
time the models per make will vary from year-to-year. That
being the case you probably should be considering a three
variable situation (Make, year, model) rather than a two
variable situation.

--
Jerry Gitomer
adam
Guest
 
Posts: n/a
#4: Jul 17 '05

re: dynamic dropdown box


thanks so far guys. i think i will opt for the database option
although i am not sure how i should set this up ie tables etc.
Gary L. Burnore
Guest
 
Posts: n/a
#5: Jul 17 '05

re: dynamic dropdown box


On 1 Dec 2004 10:49:57 -0800, adamnichols45@hotmail.com (adam) wrote:
[color=blue]
>thanks so far guys. i think i will opt for the database option
>although i am not sure how i should set this up ie tables etc.[/color]

The database option for what? What guys? What tables?

Please don't snip _EVERYTHING_ you're replying to.
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Henk Verhoeven
Guest
 
Posts: n/a
#6: Jul 17 '05

re: dynamic dropdown box


Jerry Gitomer wrote:[color=blue]
> Unless you enjoy spending a lot of time modifying programs you
> should use a database.[/color]
I agree. But that does not say you can not use javascript too. You can
use php to generate a javascript using data from a database. The
javascript puts a javascript-array into a javascript-variable that will
later be used to populate the second dropdown when a selection is made
with the first one. The advantage will be that, once the page is
downloaded, the population of the second dropdown will be very fast. Of
course at the cost of a larger page that will take longer to download.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

Geoff Berrow
Guest
 
Posts: n/a
#7: Jul 17 '05

re: dynamic dropdown box


I noticed that Message-ID: <cooeb7$t9c$1@news6.zwoll1.ov.home.nl> from
Henk Verhoeven contained the following:
[color=blue]
>The advantage will be that, once the page is
>downloaded, the population of the second dropdown will be very fast. Of
>course at the cost of a larger page that will take longer to download.[/color]

And being not useable to people without JavaScript enabled.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jamie Isaacs
Guest
 
Posts: n/a
#8: Jul 17 '05

re: dynamic dropdown box


Geoff Berrow wrote:[color=blue]
> I noticed that Message-ID: <cooeb7$t9c$1@news6.zwoll1.ov.home.nl> from
> Henk Verhoeven contained the following:
>
>[color=green]
>>The advantage will be that, once the page is
>>downloaded, the population of the second dropdown will be very fast. Of
>>course at the cost of a larger page that will take longer to download.[/color]
>
>
> And being not useable to people without JavaScript enabled.
>[/color]

I guess Iframes are out of the question also? Is there not a common
ground for browser UI yet?
Ginzo
Guest
 
Posts: n/a
#9: Jul 17 '05

re: dynamic dropdown box


On Thu, 09 Dec 2004 08:40:40 -0600, Jamie Isaacs <jamie@shsu.edu>
wrote:
[color=blue]
>Geoff Berrow wrote:[color=green]
>> I noticed that Message-ID: <cooeb7$t9c$1@news6.zwoll1.ov.home.nl> from
>> Henk Verhoeven contained the following:
>>
>>[color=darkred]
>>>The advantage will be that, once the page is
>>>downloaded, the population of the second dropdown will be very fast. Of
>>>course at the cost of a larger page that will take longer to download.[/color]
>>
>>
>> And being not useable to people without JavaScript enabled.
>>[/color]
>
>I guess Iframes are out of the question also? Is there not a common
>ground for browser UI yet?[/color]

Well the iframe is completely proprietary. JavaScript at least is
reasonably well standardized - or at least, it is possible to write
JavaScript that runs across browsers.

As for disabling JavaScript, that is a user choice - and at some
point, you have to ask what is a reasonable expectation of your user.
If you don't set a standard like that, you'll kill yourself tring to
consider all the possibilities. That's no to say your standard can't
be to assume JavScript is not available on your target client and I
know, there are some problematic capabilities in Javascript; but
nothing to the extent that it makes sense to cut off your nose to
spite your face.


Ciao,


Ginzo
---------------------------------
War is god's way of teaching
Americans geography
-- Ambrose Bierce
---------------------------------
Closed Thread


Similar PHP bytes