Selecting categories using select html

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Selecting categories using select html

Post by bagi »

Hello all,
I'm creating an internet shop and when an user will add a stuff, he will select category. I think that create <optgroup> is bad idea (you understand why). Because I wanna create <select> where user will choose general category and after that near with selected category should shows other select with subcategories (if they are). And i have two ways to do it
1) Create first select using php and after create others using javascript ajax (request from server subcategories)
2) Using php output into page all categories and after choosing general category, somehow create select with subcategories

What do u think? Or there is an another better way?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Selecting categories using select html

Post by Christopher »

I think Ajax is probably the best way to generate sub-<select>s
(#10850)
CoursesWeb
Forum Newbie
Posts: 18
Joined: Mon Dec 09, 2013 10:52 am

Re: Selecting categories using select html

Post by CoursesWeb »

Hi
Try look on the net for: "Multiple select dropdawn with ajax" , there are some good tutorials and script to make those select lists.
Post Reply