Results 1 to 3 of 3

Thread: Display Divs w/Function problem

  1. #1
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Display Divs w/Function problem

    Hello,

    I have the following code:

    Code:
     
    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script language="javascript" type="text/javascript">
    function switchDiv(div1,div2,div3,div4,div5) {
    document.getElementById(div1).style.display = 'block';
    document.getElementById(div2).style.display = 'none';
    document.getElementById(div3).style.display = 'none';
    document.getElementById(div4).style.display = 'none';
    document.getElementById(div5).style.display = 'none';
    }
    </script>
    </head>
    
    <body>
    
    <a href="#" onClick="switchDiv(name1, name2, name3, name4, name5);">Trial 1</a><br>
    <a href="#" onClick="switchDiv(name2, name1, name3, name4, name5);">Trial 2</a><br>
    <br>
    
    
    <div id="name1">DIV1</div>
    <div id="name2">DIV2</div>
    <div id="name3">DIV3</div>
    <div id="name4">DIV4</div>
    <div id="name5">DIV5</div>
    </body>
    </html>
    I keep getting an object required javascript error. Does anyone know why this is occurring? I'm sure it's something simple, but I'm not sure what it is.

    Thanks in advance for any help you can provide me with!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Should be:

    Code:
    <a href="#" onClick="switchDiv('name1', 'name2', 'name3', 'name4', 'name5');">Trial 1</a><br>
    <a href="#" onClick="switchDiv('name2', 'name1', 'name3', 'name4', 'name5');">Trial 2</a><br>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John!

    I knew it was something simple I was overlooking. Thanks again!

Bookmarks

Posting Permissions

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