...

View Full Version : How Do I Display Various DIVs?



TheRoper
06-05-2004, 08:52 PM
hi all...

i am somewhat of a newbie, so here it goes... i have a simple table which contains various links in it (to audio/video files)... what i want to have happen is that by default, all DIVs (which contain the file sizes for their respective links) are invisible, then when the user onMouseOver's one of the links, it displays the file size of that file adjacent to the link (and all other DIVs remain invisible), then of course onMouseOut all DIVs are invisible... essentially, i want each link to show its own file size onMouseOver... i want to avoid calling a separate function for each link, so i think i may have to use an array??? but i don't know how to do that at all, or if it is even necessary, or what an array is, really... preferably a cross-browser solution, but it really only needs to work in IE...

thanks in advance,
TheRoper

here is the just of my coding so far, and i know it's way off:

<HTML>
<HEAD>
<TITLE>Audio/Video Files</TITLE>

<SCRIPT language="javascript" type="text/javascript"><!--

function audioIn() {
document.all['a1'].style.display = "block";
}

function audioOut() {
document.all['a1'].style.display = "none";
}

function videoIn() {
document.all['v1'].style.display = "block";
}

function videoOut() {
document.all['v1'].style.display = "none";
}

//--></SCRIPT>

</HEAD>

<BODY>

<a href="audiofile1.mp3" onMouseOver="audioIn()" onMouseOut="audioOut()">AUDIO LINK 1</a><DIV id="a1" style="display:none">420Kb</DIV>
<a href="audiofile2.mp3" onMouseOver="audioIn()" onMouseOut="audioOut()">AUDIO LINK 2</a><DIV id="a2" style="display:none">324Kb</DIV>
...

<a href="videofile1.mpg" onMouseOver="videoIn()" onMouseOut="videoOut()">VIDEO LINK 1</a><DIV id="v1" style="display:none">651Mb</DIV>
<a href="videofile2.mpg" onMouseOver="videoIn()" onMouseOut="videoOut()">VIDEO LINK 2</a><DIV id="v2" style="display:none">984Mb</DIV>
...

</BODY>
</HTML>

there are 13 audio files and 13 video files in total, i want each to display a seperate DIV...

thanks again...
TheRoper

Basscyst
06-05-2004, 09:11 PM
Would somthing like this suit your needs?



<HTML>
<HEAD>
<TITLE>Audio/Video Files</TITLE>
<style type="text/css">
#sizes span
{
display:none;
}
</style>

<SCRIPT language="javascript" type="text/javascript"><!--

function showSize(obj)
{
document.getElementById(obj).style.display='inline';
}

function hideSize(obj)
{
document.getElementById(obj).style.display='none';
}

//--></SCRIPT>

</HEAD>

<BODY>

<table>
<tr>
<td><a href="#" onmouseout="hideSize('size1');" onmouseover="showSize('size1');">Link1</a></td>
<td><a href="#" onmouseout="hideSize('size2');" onmouseover="showSize('size2');">Link2</a></td>
<td><a href="#" onmouseout="hideSize('size3');" onmouseover="showSize('size3');">Link3</a></td>
<td><a href="#" onmouseout="hideSize('size4');" onmouseover="showSize('size4');">Link4</a></td>
<td><a href="#" onmouseout="hideSize('size5');" onmouseover="showSize('size5');">Link5</a></td>
<td><a href="#" onmouseout="hideSize('size6');" onmouseover="showSize('size6');">Link6</a></td>
</tr>
<tr id="sizes">
<td><span id="size1">400k</span></td>
<td><span id="size2">400k</span></td>
<td><span id="size3">400k</span></td>
<td><span id="size4">400k</span></td>
<td><span id="size5">400k</span></td>
<td><span id="size6">400k</span></td>
</tr>
</table>

</BODY>
</HTML>


Basscyst

TheRoper
06-05-2004, 09:30 PM
thank you so much, basscyst!

it works wonderfully... i really appreciate it!!! i've kind of been struggling with this problem for a while... thank you! :thumbsup:

adios,
TheRoper

Basscyst
06-05-2004, 09:36 PM
You could also achieve a similar effect simply by putting the title attribute in the <a> tag. You should do it anyway for those with JavaScript disabled.



<a href="#" title="400k" onmouseout="hideSize('size1');" onmouseover="showSize('size1');">Link1</a>


Basscyst



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum