Hii I have a query...I am using PHP,Mysql and Javascript..
I want to add values in the listbox from textbox..and also display them in hirerachical manner using treeview or <li> tag...so please send me code for performing this process.
Thank you..

Recommended Answers

All 6 Replies

If you are populating the listbox from a table, just add the value of the textbox to that table.

That i know but how can i display that items in the form of hierarchical tree?because in PHP there is no control available in dreamviewer for treeview...i want the format for example u select COMPUTER from listbox and type MOUSE in textbox then after submitting the value of textbox must add to the listbox and on page at the same time it will display like
COMPUTER
MOUSE

now at next cycle if u select MOUSE from listbox and type OPTICAL in textbox than OPTICAL will added to listbox and the tree will display like
COMPUTER
MOUSE
OPTICAL

And u select COMPUTER and type KEYBOARD than
COMPUTER
MOUSE
OPTICAL
KEYBOARD

And so on....
I was try it since on week but when i submit the page the previouse values are loss..
So if u have idea than please send me the code.....

I completed upto the adding of values from textbox to listview using javascript..
if u have javascript code than also it is ok...but it must be for PHP not for ASP...

Thank u for reply

If you show us the code, it would be much easier for us to know what you are really aiming at. Aren't you storing these values in the database ? If your answer is yes, then its pretty simple. Eg. table1 and table2. table1 has all the hardware entries like mouse, keyboard,printer with a unique id, say, device_id which acts like primary key. In table2, make device_id as foreign key, and add different types of hardware items of table1. so, it would be like,
Table1
device_id - 1
device_name - mouse
...

Table2
device_id - 1 (which is a foreign key and it relates mouse of table1)
sub_device_id - 1
sub_device_name - optical
device_id - 1
sub_device_id - 2
sub_device_name - scroll
..
etc

This would make your life much easier if you want a tree view.

And while adding, if the user selects mouse, adds something in the textbox and hits submit, it is added to table2 and while listing, you can use a subquery to first list main device and then, its sub_devices.

Hi nav33n,

May I suggest using modified preorder tree traversal for the tree handling logic. It has worked wonders for me in every instance of tree traversal I have encountered. Take a look and see if you can put it to use for your situation:

http://www.sitepoint.com/article/hierarchical-data-database/

Have fun :)

Hi nav33n,

May I suggest using modified preorder tree traversal for the tree handling logic. It has worked wonders for me in every instance of tree traversal I have encountered. Take a look and see if you can put it to use for your situation:

http://www.sitepoint.com/article/hierarchical-data-database/

Have fun :)

Hi, I am not the one who wanted the treeview. But hey! thanks for the link.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.