...

View Full Version : Javascript toggle



rgrs2007
07-05-2012, 07:15 PM
i am using javascript to toggle and to change font color of links but my div have jsp include syntax because of which toggling works only for two divs but beyond that it stop working. Any help is greatly appreciated.

function toggle(data)
{
if(data=="details_name1")
{
document.getElementById("img1").src="pics/change_arroe.png";
document.getElementById("img2").src="pics/arrow.png";
document.getElementById("img3").src="pics/arrow.png";
document.getElementById("details_name1").style.display="block";
document.getElementById("details_name2").style.display="none";
document.getElementById("details_name3").style.display="none";
document.getElementById("content_font1").style.color="#7A0017";
document.getElementById("content_font2").style.color="#016AA2";
document.getElementById("content_font3").style.color="#016AA2";
}

The same code goes for other divs. This code is present in user.jsp which along with above code have two includes:
<%@include file="user_contents.jsp" %>
<%@include file="user_details.jsp" %>

user_contents.jsp:
<div id="content_css">
<p>
<a href="javascript:void(0)" onclick="toggle('details_name1')" id="a_style"> <img src="pics/arrow.png" id="img1">
<font id="content_font1">
Draft a proposal
</font>
</a>
</p>
</div>
Similarly other divs

user_details.jsp:
<div class="details_css" id="details_name1" style="display:block">
<%@include file="form.jsp" %>
</div>
similarly other divs

user_contents act as menu and user_details act as target.
Please help me i need to submit it tomorrow.
Thank you

I suppose you are asking for user_details page:

<div class="details_css" id="details_name1" style="display:block">
<%@include file="form.jsp" %>
</div>

<div class="details_css" id="details_name2" style="display:none">
<%@include file="approval.jsp" %>
</div>

<div class="details_css" id="details_name3" style="display:none">
<%@include file="moving_list.jsp" %>
</div>

user_content:
<div id="content_css">
<p>
<a href="javascript:void(0)" onclick="toggle('details_name1')" id="a_style">
<img src="pics/arrow.png" id="img1">
<font id="content_font1"> Draft a proposal </font>
</a>
</p>

<p>
<a href="javascript:void(0)" onclick="toggle('details_name2')" id="a_style">
<img src="pics/arrow.png" id="img2">
<font id="content_font2"> Pending Work Permits </font>
</a>
</p>

<p>
<a href="javascript:void(0)" onclick="toggle('details_name3')" id="a_style">
<img src="pics/arrow.png" id="img3">
<font id="content_font3"> Acting in one's absence </font>
</a>
</p>

</div>
@nomiac at the moment i am sure i would have committed any silly mistakes :(

nomanic
07-05-2012, 07:22 PM
might be a silly question but are all the named mentioned ids definately present in the page?
as in all the img1,img2,img3,etc

can you show the whole outputted page? or is it up somewhere?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum