MyBB Community Forums

Full Version: Javascript mouseover trigger
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I'm starting to code my own javascript for my skins so I decided to make a small script to start out, it works perfectly except it only displays the forum info on the FIRST forum and none of the others, it will display the stats of all the other forums, but it will still be on the first forum/trow.
_________
Forum 1 (always displays text here on mouseover)
_________
Forum 2 (even if I hover over this forum, only changing the stats/text)
_________

Jscript:
function writeText(var)
{document.getElementById("forum_stats").innerHTML=var;}

HTML:
<td class="{$bgcolor}" valign="middle" onmouseover="writeText('({$posts}{$unapproved['unapproved_posts']} {$lang->forumbit_posts},  {$threads}{$unapproved['unapproved_threads']} {$lang->forumbit_threads})')" onmouseout="writeText('')"">

<span class="forum_title"><a href="{$forum_url}">{$forum['name']}</a></span>

<span id="forum_stats"></span>

Any suggestions for the script to fix this? Or is a php conflict?


You have to give a unique id to every span so that they can be differentiated. Right now all your forums spans have the id forum_stats so only the first one will be recognized. Differentiate them by making them unique such as forum_stats1, forum_stats2 and so on

Then when the mouse is over that particular forum you would also pass the name of the span or just the number back to the jcsript function so that your jscript will know which forum to show it on.