SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple JS Does Not Work in Opera

    Hi,

    I have this code below:
    Code:
    <html>
    <head>
        <title> New Document </title>
    
        <script src="prototype.js" type="text/javascript"></script>
        <script type="text/javascript">
    
        function loadInfoBox(id)
        {
            var check = $('qd-' + id);
            var link = $('h-' + id);
    
            if (check == undefined)
            {
                new Insertion.After('q-' + id, ' <tr id="qd-' + id + '"><td colspan="99"><div id="div-' + id + '">Dynamic info here!</div></td></tr>');
    
    //          var getDetails = new Ajax.Updater('div-' + id,
    //              'getDetails.php',
    //              {
    //                  method: 'get', 
    //                  parameters: 'id=' + id
    //              });
                
                Element.update(link, 'Hide Details');
            }
            else
            {
                Element.update(link, 'Show Details');
                Element.remove(check);
            }   
        }
    
        </script>
    </head>
    
    <body>
    <table width="100%" cellpadding="2" cellspacing="0" border="1">
     <tr>
        <th>ID</th>
        <th>Name</th>
        <th></th>
     </tr>
     <tr id="q-5">
        <td>5</td>
        <td>Test</td>
        <td><a href="javascript:;" onClick="loadInfoBox(5)" id="h-5">Show Details</a></td>
     </tr>
    </table>
    </body>
    </html>
    Basically the user clicks on Show Details and the script inserts a table row beneath the current row with some details generated from the Ajax call. This code works fine in FF 1.5 and IE 6, but fails on Opera 9. It keeps inserting multiple rows in the table. It *should* simply hide the table row if pressed again, but does not. Any suggestions?

    -Ben

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nobody has any idea why this does not work?

  3. #3
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is probably a silly question, but you do have JavaScript enabled in Opera right? Tools > Preferences > Advanced > Content > Enable JavaScript

  4. #4
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the script inserts a new table row as planned, but in Opera it just keeps inserting more. It should remove the row when pressed again. This part does not work in Opera, but works fine in IE and FF.


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
  •