Results 1 to 2 of 2

Thread: onclick add column and image

  1. #1
    dattapuro
    Guest

    Exclamation onclick add column and image

    Hi there,

    How do I insert columns when I click on the button. Below written code inserts rows when I click on the button.

    <html>
    <head>
    <title> Add A Row </title>
    <script language="JavaScript">
    function addRow(id){
    var tbody = document.getElementById
    (id).getElementsByTagName("TBODY")[0];
    var row = document.createElement("TR")
    var td1 = document.createElement("TD")
    td1.appendChild(document.createTextNode("column 1"))
    var td2 = document.createElement("TD")
    td2.appendChild (document.createTextNode("column 2"))
    row.appendChild(td1);
    row.appendChild(td2);
    tbody.appendChild(row);
    }
    </script>
    </head>
    <body>
    <a href="javascript:addRow('myTable')">Add row</a>&nbsp;&nbsp;
    <input type="button" value="Add Row" onclick="javascript:addRow('myTable');"><br><br>
    <table id="myTable" cellspacing="0" border="1">
    <tbody>
    <tr>
    <td>row1_column1</td>
    <td>row1_column2</td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>

    thanx
    dp

  2. #2
    scoutt
    Guest
    to vreat a column, just take out

    var row = document.createElement("TR")

    and it should just create columns.

Posting Permissions

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



Click Here to Expand Forum to Full Width