G
Giggle Girl
Hi there,
I have a nav tree similar to the XP Windows Explorer in behavior. It
uses styles to underline a row on mouseover, and change the look of a
row when clicked.
Currently, it is working fine using CSS/Javascript, by calling
functions that underline and highlight by passing in IDs.
The problem is, I do not want to pass in IDs. Currently it has one the
TDs to be changed, but I may need to add one for images (to change the
look of a plus to minus) and many other things. Instead I would like a
way of passing the row index, and having it "walk through the DOM" to
change behavior, picking the correct child nodes to change the
appearance. Can this be done?
It is for an intranet app and only needs to work with IE 6 (and later).
Thanks!
Ann
Here is the current working javascript:
var old_clicked_tree_nav = -1 // initially there is no row
highlighted...
function hover_tree_nav(row_id,bool)
{
if(document.getElementById('td_' + row_id).className !=
'nav_selected')
{
if(bool==1)
document.getElementById('td_' + row_id).className='nav_highlighted'
else
document.getElementById('td_' + row_id).className='nav_normal'
}
}
function click_tree_nav(row_id, do_action)
{
// turn off old highlight
if(old_clicked_tree_nav > -1)
document.getElementById('td_' +
old_clicked_tree_nav).className='nav_normal'
old_clicked_tree_nav = row_id
// make new highlight
document.getElementById('td_' + row_id).className='nav_selected'
}
And here is one snip of the tree:
<tbody>
<tr id="tr_0"><td onclick="click_tree_nav(0, 0)"><span
id="span_0"><table class="tree_nav_interior"><tr><td><img
src="../images/tree_minus.gif" align="absmiddle"></td><td id="td_0"
class="nav_normal" onmouseover="hover_tree_nav(0,1)"
onmouseout="hover_tree_nav(0,0)"><img
src="../images/tree_folder_open.gif" align="absmiddle">Owned
Deals</td></tr></table></span></td></tr>
<!-- daddy --><tr id="tr_1"><td onclick="click_tree_nav(1, 0)"><span
id="span_1"><table class="tree_nav_interior"><tr><td><img
src="../images/tree_spacer.gif"><img src="../images/tree_minus.gif"
align="absmiddle"></td><td id="td_1" class="nav_normal"
onmouseover="hover_tree_nav(1,1)" onmouseout="hover_tree_nav(1,0)"><img
src="../images/tree_folder_open.gif" align="absmiddle">Deal
A</td></tr></table></span></td></tr>
I have a nav tree similar to the XP Windows Explorer in behavior. It
uses styles to underline a row on mouseover, and change the look of a
row when clicked.
Currently, it is working fine using CSS/Javascript, by calling
functions that underline and highlight by passing in IDs.
The problem is, I do not want to pass in IDs. Currently it has one the
TDs to be changed, but I may need to add one for images (to change the
look of a plus to minus) and many other things. Instead I would like a
way of passing the row index, and having it "walk through the DOM" to
change behavior, picking the correct child nodes to change the
appearance. Can this be done?
It is for an intranet app and only needs to work with IE 6 (and later).
Thanks!
Ann
Here is the current working javascript:
var old_clicked_tree_nav = -1 // initially there is no row
highlighted...
function hover_tree_nav(row_id,bool)
{
if(document.getElementById('td_' + row_id).className !=
'nav_selected')
{
if(bool==1)
document.getElementById('td_' + row_id).className='nav_highlighted'
else
document.getElementById('td_' + row_id).className='nav_normal'
}
}
function click_tree_nav(row_id, do_action)
{
// turn off old highlight
if(old_clicked_tree_nav > -1)
document.getElementById('td_' +
old_clicked_tree_nav).className='nav_normal'
old_clicked_tree_nav = row_id
// make new highlight
document.getElementById('td_' + row_id).className='nav_selected'
}
And here is one snip of the tree:
<tbody>
<tr id="tr_0"><td onclick="click_tree_nav(0, 0)"><span
id="span_0"><table class="tree_nav_interior"><tr><td><img
src="../images/tree_minus.gif" align="absmiddle"></td><td id="td_0"
class="nav_normal" onmouseover="hover_tree_nav(0,1)"
onmouseout="hover_tree_nav(0,0)"><img
src="../images/tree_folder_open.gif" align="absmiddle">Owned
Deals</td></tr></table></span></td></tr>
<!-- daddy --><tr id="tr_1"><td onclick="click_tree_nav(1, 0)"><span
id="span_1"><table class="tree_nav_interior"><tr><td><img
src="../images/tree_spacer.gif"><img src="../images/tree_minus.gif"
align="absmiddle"></td><td id="td_1" class="nav_normal"
onmouseover="hover_tree_nav(1,1)" onmouseout="hover_tree_nav(1,0)"><img
src="../images/tree_folder_open.gif" align="absmiddle">Deal
A</td></tr></table></span></td></tr>