SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript enlarging table

    I want a table to be bigger (or smaller) with some pixels after i clicked a button.
    Now what i have is this :
    Code:
    <script language="JavaScript">
    function test()
    {
    var test0r = document.getElementById("TopTable").width;
    document.getElementById("TopTable").setAttribute("width", test0r += 10);
    }
    </script>
    
    
    <table border=1 id="TopTable">
    
    <tr>
           <td>nerd</td>
    </tr>
    </table>
    
    <input type="button" value="Klik!" onclick="test();">
    It does something though, it just makes the table 10 times bigger or so

    anyone has an idea on how to fix this bug / problem?

    thx in advance
    _o_ OOP _o_

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <html>
    <head>
    <title>Test</title>
    <style type="text/css">
    #TopTable {
      width: 60px;
    }
    </style>
    <script language="JavaScript">
    var width = 60;
    function test()
    {
      width += 10;
      document.getElementById("TopTable").style.width = width + 'px';
    }
    </script>
    
    <body>
    <table border="1" id="TopTable">
    
    <tr>
           <td>nerd</td>
    </tr>
    </table>
    
    <input type="button" value="Klik!" onclick="test();">
    </body>
    </html>
    Try that out.

    -xDev

  3. #3
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works perfectly, great!

    thanks a lot man
    _o_ OOP _o_


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
  •