...

View Full Version : I'm completely javascript illiterate so please help



TheQuestor
12-18-2010, 04:10 PM
<%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 :)

vwphillips
12-18-2010, 05:42 PM
<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum