Creating a category tree

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello all,

I am working on a website for a bookstore and have run into a bit of a snag.
I am trying to write a form where an admin can set the category for a book.
However, categories can be of an arbitrary depth so I need something which
resembles a windows "tree view."  For example:

Primary category Art and Architecture
has subcategory history
has subcategory African etc etc.

I can't say in advance how deep the tree will go so don't know how many
select boxes to place on the form.  Are there any examples out there of a
similar construction I can learn from.  Though I do know html/cgi, I'm no
JavaScript/dhtml expert which I assume this will involve.  From the
backend's point of view, the page would probably have to, when a category
was selected, query the server which would return any subcategories, that
part is simple enough.  It's the frontend I am not sure of.


Re: Creating a category tree wrote:
Quoted text here. Click to load it
   Server-side programs like PHP, JSP, ASP and even perl are often used to
create dynamically generated pages. CGI is less common because it's
noticeably more difficult to use.
   Web commerce/shopping programs often have support for categories.
Search for some that make the source code available.

jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Re: Creating a category tree wrote:
Quoted text here. Click to load it

Try >>>--  comp.lang.javascript  -->

In the meantime, you may want to have a look at how your thesaurus might
be delivered - for example, when "Art and Architecture" are selected,
fill a second select with all the sub-categories including 'history',
which when selected creates a third select with the categories with
'african', etc.

There is an article on XMLHttpRequest here:


And a cross-browser example here:


Site Timeline