Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript toggle

    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
    Last edited by rgrs2007; 07-05-2012 at 08:30 PM.

  • #2
    Regular Coder nomanic's Avatar
    Join Date
    Feb 2009
    Location
    United Kingdom
    Posts
    255
    Thanks
    9
    Thanked 33 Times in 33 Posts
    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?
    <DmncAtrny> I will write on a huge cement block "BY ACCEPTING THIS BRICK THROUGH YOUR WINDOW, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE INSTALLATION OF THIS BRICK INTO YOUR BUILDING."
    <DmncAtrny> And then hurl it through the window of a Sony officer
    <DmncAtrny> and run like hell

    Portfolio, Tutorials - http://www.nomanic.biz/


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •