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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How Do I Display Various DIVs?

    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

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Would somthing like this suit your needs?

    Code:
    <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
    Helping to build a bigger box. - Adam Matthews

  • #3
    New Coder
    Join Date
    Jun 2004
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

    adios,
    TheRoper

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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.

    Code:
    <a href="#" title="400k" onmouseout="hideSize('size1');" onmouseover="showSize('size1');">Link1</a>
    Basscyst
    Helping to build a bigger box. - Adam Matthews


  •  

    Posting Permissions

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