Ok
now i have changed the javascript function switchMenu into two
functions which are as follows:
<script type="text/javascript">
document.getElementById
('personal_details').style.display='block';
document.getElementById
('income_details').style.display='block';
document.getElementById
('return_details').style.display='block';
document.getElementById
('filing_details').style.display='block';
document.getElementById
('aboutyou').style.display='block';
document.getElementById
('otherdetail').style.display='block';
document.getElementById
('income').style.display='block';
document.getElementById
('deductions').style.display='block';
document.getElementById
('relief').style.display='block';
document.getElementById
('taxes').style.display='block';
document.getElementById
('itrpreview').style.display='block';
document.getElementById
('reviewerrors').style.display='block';
document.getElementById
('otherinfo').style.display='block';
document.getElementById
('payment').style.display='block';
document.getElementById
('downloadreturn').style.display='block';
document.getElementById
('efile').style.display='block';
function collapseMenu(id)
{
obj=document.getElementById(id);
col=document.getElementById("x" + id);
if
(obj.style.display=='block')
{
obj.style.display='none';
col.innerHTML="<img src='/it_media/v4/n/images/plus2.gif'/>";
}
}
</script>
<script type="text/javascript">
document.getElementById
('personal_details').style.display='none';
document.getElementById
('income_details').style.display='none';
document.getElementById
('return_details').style.display='none';
document.getElementById
('filing_details').style.display='none';
document.getElementById
('aboutyou').style.display='none';
document.getElementById
('otherdetail').style.display='none';
document.getElementById
('income').style.display='none';
document.getElementById
('deductions').style.display='none';
document.getElementById
('relief').style.display='none';
document.getElementById
('taxes').style.display='none';
document.getElementById
('itrpreview').style.display='none';
document.getElementById
('reviewerrors').style.display='none';
document.getElementById
('otherinfo').style.display='none';
document.getElementById
('payment').style.display='none';
document.getElementById
('downloadreturn').style.display='none';
document.getElementById
('efile').style.display='none';
function expandMenu(id)
{
obj=document.getElementById(id);
col=document.getElementById("x" + id);
if
(obj.style.display=='none')
{
obj.style.display='block';
col.innerHTML="<img src='/it_media/v4/n/images/minus2.gif'/>";
}
}
</script>
But the problem now is when I bring mouseout from first level the menu
collpases and i am not able to select the secondlevel menu. i.e
after taking mouse away from level 1, I am not able to select level 11
as leve 1 collapses.
Please read my earlier post before answering the query.
Le 9/16/09 12:41 PM, neetu a écrit :
where is your html code
we don't know how you try to use the script(s)
Not understood,
if the menu is hidden when you leave the [-] image
how do you expect the user could click one of the links ?
But the menu
keeps on collapsing and expanding once the mouse is over the +
image.It does not stops for the user to click on the menu item.
mouseover and out to put(drag) in the IMG ?
On Sep 16, 1:38 am, SAM <
[email protected]>
wrote:
<script type="text/javascript">
document.getElementById('personal_details').style.display='none';
document.getElementById('income_details').style.display='none';
document.getElementById('return_details').style.display='none';
document.getElementById('filing_details').style.display='none';
function switchMenu(id)
{
var obj = document.getElementById(id).style;
var col = document.getElementById("x" + id);
obj.display = obj.display=='none'? 'block' : 'none';
col.innerHTML = "<img src='/it_media/v4/n/images/" +
(obj.display=='none'? 'plus' : 'minus') + "2.gif'/>";
}
// variante using preloaded images (once for all the menus):
if(document.images) {
plus = new Image();
minus = new Image();
plus.src = '/it_media/v4/n/images/plus2.gif';
minus.src = '/it_media/v4/n/images/minus2.gif';
}
function switchMenu(id)
{
var obj = document.getElementById(id).style;
var col = document.getElementById("x" + id);
col = col.getElementsByTagName('IMG')[0];
obj.display = (obj.display=='none')? 'block' : 'none';
col.src = (obj.display=='none')? plus.src : minus.src;
}
</script>
<div class="menu"
onmouseover="switchMenu('personal_details');"
onmouseout="switchMenu('personal_details');">
<div id="xpersonal_details">
<img src='/it_media/v4/n/images/plus2.gif'/>
Personal details
</div>
<div id="personal_details">
<a href="blah.htm">blah</a>
<a href="blah1.htm">blah 1</a>
<a href="blah2.htm">blah 2</a>
</div>
</div>
<div class="menu"
onmouseover="switchMenu('income_details');"
onmouseout="switchMenu('income_details');">
<div id="xincome_details">
<img src='/it_media/v4/n/images/plus2.gif'/>
Income details
</div>
<div id="income_details">
<a href="blah.htm">blah</a>
<a href="blah1.htm">blah 1</a>
<a href="blah2.htm">blah 2</a>
</div>
</div>
Let me explain my problem in detail.I have a three level menu like
this:
[+]level 1
[+]level 11
[+]level 12
[-]level 13
level 131
level 132
level 133
[+]level 2
and so on.
I want to make the above menu using html and javascript and I dont
know javascript at all.I found the below javascript for expand/
collapse menu on net.
<script type="text/javascript">
document.getElementById('level_1').style.display='none';
document.getElementById('level_2').style.display='none';
document.getElementById('level_3').style.display='none';
document.getElementById('level_4').style.display='none';
function switchMenu(id)
{
obj=document.getElementById(id);
col=document.getElementById("x" + id);
if (obj.style.display=='none')
{
obj.style.display='block';
col.innerHTML="<img src='/it_media/v4/n/images/minus2.gif'/>";
}
else
{
obj.style.display='none';
col.innerHTML="<img src='/it_media/v4/n/images/plus2.gif'/>";
}
}
</script>
While using this script i found that when user clicks on level 1 [+]
image, the menu collapses, but what I want is the menu should collpase
on onmouseover and expand on onmouseout.
and my HTML code is like this:
<div class="menu" onmouseover="switchMenu('level_1');"
onmouseout="switchMenu('level_1');">
<div id="xlevel_1">
<img src='/it_media/v4/n/images/plus2.gif'/>
level 1
</div>
<div id="level_1">
<div id="xlevel_11">
<img src='/it_media/v4/n/images/plus2.gif'/>
level 11
</div>
<div id="level_11">
<ul>
<li class="item">
<a href="url" title=" ">level111</
a>
</li>
<li class="item">
<a href="url" title=" ">level112</a>
</li>
</ul>
</div>
</div>