473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tree view

Fary4u
273 Contributor
Hi

i'm trying to do treeview
it's working fine but when some body click on the link1 or link2 when the page open it's bring the same list already open

if possible then the link has file link but at the moment it li options

coding rite here in line 32, 39 or 46

[PHP]
<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
*{list-style:none;font:12px Tahoma;color:#567;margin:0;}
ul li ul{display:none;margin-left:10px}
ul li.active ul{display:block;}
li{clear:both;float:left;cursor:pointer}
</style>
<script type="text/javascript">
function treeView(event)
{
var target = event.target || window.event.srcElement;
if (target.tagName == 'LI')
{
if (target.className!='active')
{
target.className='active';
}
else
{
target.className='';
}
}
}
</script>
</head>
<body>
<ul onclick="treeView(event)">
<li>link 1
<ul>
<li><a href="dsafa">sublink</a></li>
<li><a href="fdsa23">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li>link 2
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li>link 3
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
</ul>
</body>
</html>
[/PHP]
Jul 2 '08 #1
19 2418
acoder
16,027 Recognized Expert Moderator MVP
when some body click on the link1 or link2 when the page open it's bring the same list already open
Could you explain what you mean here? I'm not sure I quite follow what you're saying.
Jul 2 '08 #2
Fary4u
273 Contributor
Thx for kindly reply

well question is i've got three link like
[PHP]Link 1
Link 2
Link 3[/PHP]in javascript somebody click on Link 1 it bring subnode like

[PHP]
Link 1
Link 1-1
Link 1-2
Link 2
Link 3
[/PHP]

iv'e got the code which works fine but when click on Link 1 it's brings the subnode

but i want same time open a file & also open subnode as well
when the file opening it's automaticaly know which node is selected

i've just paste the code above if u just run the script you get know what i want.

thx in advance
Jul 3 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
What file(s) would you like to open? Are you looking to download a file or do you mean opening a page?
Jul 3 '08 #4
Fary4u
273 Contributor
Hi

actually i'm working on asp with database connectivity
& search a result from database & opening a new page & but it's gonna check if link 1 clicked then it's automatically open's subnode as well on the same time

is that possible in this coding which is above ?
Jul 3 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
In that case, pass the li id to the page that you're linking to and in your ASP code, if an id is passed, set the li class to active inline. Alternatively, you could use JavaScript, e.g. set/retrieve cookies, but that would show up after page load.
Jul 3 '08 #6
Fary4u
273 Contributor
is it the best way to do it in asp or javascript ?

could u plz give me some exapmle ? i'm not quite sure ?

thx
Jul 3 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
That depends on what you're most comfortable with and what suits your needs. Could there be a possibility that a user does not have JavaScript enabled? Do you need instant interactivity? If you decide to go with the ASP approach, ask in the ASP forum. If not, I can give you some tips.
Jul 3 '08 #8
Fary4u
273 Contributor
Thx for reply

yes u absoluty right i just wondering if you could sort my programming coz they way you explain me i'm trying 2 do work but giving error could you plz give some time to sort my progrmming out the way you told me ?

look forward to see your reply

Best Regards
Fary
Jul 4 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
What error message do you get? Can you post the code that you've tried?
Jul 4 '08 #10
Fary4u
273 Contributor
[PHP]
<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
*{list-style:none;font:12px Tahoma;color:#567;margin:0;}
ul li ul{display:none;margin-left:10px}
ul li.active ul{display:block;}
li{clear:both;float:left;cursor:pointer}
</style>
<script type="text/javascript">
function treeView(event)
{
var target = event.target || window.event.srcElement;
if (target.tagName == 'LI')
{
if (target.className!='active')
{
target.className='active';
}
else
{
target.className='';
}
}
}
</script>
</head>
<body>
<ul onclick="treeView(event)">
<li><a herf="open_page_&_subnode.htm">link 1</a>
<ul>
<li><a href="subnode1.htm">sublink1</a></li>
<li><a href="subnode2.htm">sublink2</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li>link 2
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li>link 3
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
</ul>
</body>
</html>
[/PHP]
Jul 7 '08 #11
acoder
16,027 Recognized Expert Moderator MVP
"herf" should be "href". What's the error message?
Jul 7 '08 #12
Fary4u
273 Contributor
actually i'm just explain things
it's the codeing technique like opening file with subnode nothing else

I WANT OPEN NEW PAGE & SUBNODE ON THE SAME TIME

that's the same code i've upload 1st time
plz try to understand the actual scenario
Jul 7 '08 #13
acoder
16,027 Recognized Expert Moderator MVP
The problem here is that the link will open in the same window, so the tree will not open up. The link will be followed instead. Will the linked page also show the same tree that you want opened?
Jul 7 '08 #14
Fary4u
273 Contributor
Thank so much for corporation & reply

Yes you right it's not possible but if to passing values & open subnode with to judge the value ?

is it possible ? any example ?
Jul 9 '08 #15
acoder
16,027 Recognized Expert Moderator MVP
I'm sorry, but I'm not sure what you mean by this:
if to passing values & open subnode with to judge the value ?
Do you mean passing the value in the URL to open the node in the linked page?
Jul 9 '08 #16
Fary4u
273 Contributor
YES you almost know what i'm trying to do.
Jul 9 '08 #17
acoder
16,027 Recognized Expert Moderator MVP
OK, what you would need to do is pass some info. in the URL, e.g. "open_page_and_node.asp#link1". Then, either use ASP code to have the li items "block" by default or use JavaScript to open the subnode onload. Call a function onload which checks location.hash. If it's not empty, take the hash value and use it as an id, e.g. "link1". For this to work, you will need to give each list item an ID. Then use document.getElementById() to access the element and set the class to "active".

Alternatively, use cookies whenever a subnode is opened and check for cookies on the next page.
Jul 9 '08 #18
Fary4u
273 Contributor
Thanks i'm gonna try this & i've got the idea who this gonna work

one more time thx for your concern
Jul 9 '08 #19
acoder
16,027 Recognized Expert Moderator MVP
No problem. Let us know how you manage.
Jul 9 '08 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

3
10802
by: imani_technology_spam | last post by:
We need to present hierarchical data on a web page, the same way the tree view shows files in Windows Explorer. Here's the catch: that tree view needs to be bound to a SQL Server database. How...
0
2157
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
1
4893
by: Jesper DK | last post by:
Hi, I have docked a tree view to the left on a form. When I start to populate this tree view with nodes, a horizontal scroll box appears in the bottom of the tree view even though thee tree...
3
6044
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
1
2167
by: Kaye | last post by:
It seems that when I dynamically resize items in a tree-view control, using TVM_SETITEM and the TVITEMEX iIntegral member, things go awry. The window draws properly, but it seems like the RECTs for...
10
2500
by: dwok | last post by:
Does anyone know of a good article that discusses creating a "Tree View" control in ASP.NET? Or perhaps a Tree View Control that comes with source code? I have come across a lot of tree controls...
0
1410
by: rinishrk | last post by:
Hi, I have a web application that contains subfolders Admin and User with related webpages inside them. Within the Admin folder I have a page containing a Tree View Control.I want this tree view...
3
2364
by: gmail | last post by:
Hi Friends, Can any body suggest me on this. I am working on .NET 2005 Frame work 2.0 . I am facing problem using the tree stucture. I created the site map.Now i want use the site map in every...
1
4740
by: BeginingOfLife | last post by:
i am using a java script to create a tree view in my html page. i got that script from this link : http://destroydrop.com/javascripts/tree/ given script is static script creations for tree...
1
2604
by: happy.john1234 | last post by:
Hi, i have got large xml file which i have to show in tree view windows form.I tried with loading all those data at once to tree view but it took a long time to render that tree view.Now i am...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.