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
    Jun 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    I'm completely javascript illiterate so please help

    Code:
    <%Function PF(num)%>
    <script type="text/javascript">
     <!--
     function toggleOff()
     {
     document.getElementById("floatingBox").style.display = "none";
     }
     //-->
     </script>
    <div class="post_header" onClick="ToggleReply( <%=num%> )">
    <div class="post_pmbutton" id="button_<%=num%>">[+]</div>
    <br clear="all">
    </div>
    <div class="post_content" style="display: none;" id="content_<%=num%>">
    <div id="floatingBox">some words here
    <a href="#&ID=<%=num%>" title="Close this box" onclick="javascript: toggleOff();">[I Agree]</a>
     </div></div>
    <%End Function%>
    It works fine, as long as it's the only one on the page. Problem is I potentially could have many dozens on any given page and the top one always works but the ones after do not

    I understand that I basically need to set a variable that is different for each rendition of the code but that is where I am stumped.
    I have a message ID from vb that I can pass to the javascript to get each iteration a unique ID I just don't know what to do with the number in javascript. I have NO clue about javascript

    Each iteration is hidden by default until an anchor is clicked.


    Please help clue this poor soul in
    Last edited by TheQuestor; 12-18-2010 at 03:15 PM. Reason: put the stupid [/CODE] in the wrong place :(

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,502
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <script type="text/javascript">
     <!--
    function toggle(id,display){
     document.getElementById(id).style.display = display;
    }
     //-->
     </script>
    <div class="post_header" onClick="toggle('floatingBox','block');">
    <div class="post_pmbutton" id="button_<%=num%>">[+]</div>
    <br clear="all">
    </div>
    <div class="post_content" style="display: none;" id="floatingBox">
    <div id="floatingBox">some words here
    <a href="javascript:toggle('floatingBox','none');" title="Close this box" >[I Agree]</a>
     </div>
     </div>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    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
    •