Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,675 members, 7,816,773 topics. Date: Friday, 03 May 2024 at 04:49 PM

[help Request] "PHP Code" To Make Contents Of One Listbox Based Another - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / [help Request] "PHP Code" To Make Contents Of One Listbox Based Another (921 Views)

[Help Request] Help On Java download and Installation Oo! / [Help Request] Help With Database Connectivity Error / [Help Request ] I Want To Learn Programming, what are the requirements (2) (3) (4)

(1) (Reply) (Go Down)

[help Request] "PHP Code" To Make Contents Of One Listbox Based Another by RuuDie(m): 6:04am On Oct 31, 2012
Please can someone help to pace me through this!?

I have actually been trying to do this for some time now and I have seen various examples online but I just cannot grasp or make it work!

Specifically, I am looking to make the listbox items "dynamic" - as in, the contents of one listbox will be based on what is clicked inside another. For example, if you click on "Science" in one box, the other will only contain science related items like "biology", "chemistry", "physics". . .etc

Ideally I would love it as a piece of javascript code that can be embedded into my PHP - but other ideas or methods of implementing are also welcome. Any form of advise or assistance you can offer is very much appreciated!

Thanks!
Re: [help Request] "PHP Code" To Make Contents Of One Listbox Based Another by RuuDie(m): 8:35am On Oct 31, 2012
Pardon me. . .I forgot to add that the values in the second listbox will be pulled off a mySQL table!
Re: [help Request] "PHP Code" To Make Contents Of One Listbox Based Another by Nobody: 9:00am On Oct 31, 2012
you need good knowledge of jquery to populate the second list box
listen for the select event of the first listbox
then do a $.get() and on return success, populate the second listbox.


note that you have to design your database to make this work as expected
table1
id, name

table2
id, table1_id, name

table3
id, table2_id, name

etc. for unlimited number of subs
Re: [help Request] "PHP Code" To Make Contents Of One Listbox Based Another by lordZOUGA(m): 4:36pm On Oct 31, 2012
RuuDie: Please can someone help to pace me through this!?

I have actually been trying to do this for some time now and I have seen various examples online but I just cannot grasp or make it work!

Specifically, I am looking to make the listbox items "dynamic" - as in, the contents of one listbox will be based on what is clicked inside another. For example, if you click on "Science" in one box, the other will only contain science related items like "biology", "chemistry", "physics". . .etc

Ideally I would love it as a piece of javascript code that can be embedded into my PHP - but other ideas or methods of implementing are also welcome. Any form of advise or assistance you can offer is very much appreciated!

Thanks!
you can do it the way tabs are implemented... By pre-loading the contents of the second box... Then hiding and showing them as supposed. You can use the "rel" attribute to point each link on the first box to each page in the second box.
You will probably have a class called "active" that you should attach to the <div> you want shown using javascript...

(1) (Reply)

Am Still Up Coming And I Want To Be A Software Programer / The Way Foward For Computer Science Students In Imo State University / Help On This Simple Script

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.