Dinamic select box

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Minhoto
Forum Newbie
Posts: 2
Joined: Mon Mar 31, 2003 5:34 am

Dinamic select box

Post by Minhoto »

Hello,

I want to make 3 dinamic select box's
but when the page apears, only first select box is available.
when user select a value, then second select box will apears,
but the values will be get from a mysql table, an depending of the value of first select box. and thirth select box will appears when user select second value and 3º select box will get values from mysql table, depending of value of 2º select box !

Is this possible ?
can any help me ?
tanks
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

it would help if you posted your code so we understood what you were doing.

as far as i know you can change select box's dynamically ( note the spelling ;), but you will have to load all the data from mysql into the page into javascript arrays/objects as you cannot request new items for the select once the page has been loaded
Minhoto
Forum Newbie
Posts: 2
Joined: Mon Mar 31, 2003 5:34 am

Post by Minhoto »

That's the problem

I dont know how to make this !!
so i haven't any code ....

maybe you can help me finding some script that already do this ...
i know that i must use javascript ...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://uk.europe.creative.com/support/d ... elcome.asp is an example.
(no I do not work there but I have a soundblaster ...there are many other soundcards available ;) )
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

im not telling you how to do it but i suggest you look up these things:

1. javascript arrays ( declaring arrays and storing data to them )
2. javascript objects ( storing objects in arrays for more complex stuff )
3. select box onchange event ( who wants to press a button ? ;)

once you understand these you can simply generate the required javascript from php. ( im reasonalby sure this will just be a few arrays you chuck out from mysql)

a simpler soloution to changing the content of the select boxes might be to actually just use several and hide and replace them but im i think you'll just run into other difficulties
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

viewtopic.php?t=6568

Check out that thread. It is set up for 2 select boxes, but adding a third is easy. The code there does not show/hide the boxes, but rather changes the options available in descending boxes.

Function: choose option in SelectBox1. Option list in select box 2 changes.
Post Reply