Adding Remove button or link

Discussion in 'HTML & Website Design' started by jackjones010101, Jul 21, 2010.

  1. #1
    Please help me: Im with this code:

    <script>
    /*
    This script is identical to the above JavaScript function.
    */
    function new_link()
    {
    var div1 = document.createElement('div');

    div1.innerHTML = document.getElementById('newlinktpl').innerHTML;

    //var test1 = document.getElementById('newlinktpl').getElementsByTagName('table')[0];

    document.getElementById('newlink').appendChild(div1);

    }

    function remove_link()
    {


    div1.innerHTML = document.getElementById('newlinktpl').innerHTML;

    //var test1 = document.getElementById('newlinktpl').getElementsByTagName('table')[0];

    document.getElementById('newlink').appendChild(div1);

    }



    </script>

    <style>
    .feed {padding: 5px 0}
    </style>

    <form method="post" action="">

    <div id="newlink">
    <div>
    <table border=0>
    <tr>
    <td> Link URL: </td>
    <td><input type="text" name="linkurl[]2" value="http://www.satya-weblog.com"></td>
    </tr>
    <tr>
    <td> Link Description: </td>
    <td> <textarea name="linkdesc[]" cols="50" rows="5"></textarea> </td>
    </tr>
    </table>
    </div>

    </div>


    <p id="addnew">
    <a href="javascript:new_link()">Add New </a>&nbsp;&nbsp;&nbsp;

    </p>
    <p id="remove">
    <a href="javascript:remove_link()">Remove</a>&nbsp;&nbsp;&nbsp;

    </p>

    </form>

    <!-- Template -->
    <div id="newlinktpl" style="display:none">
    <div>
    <table border=0>
    <tr>
    <td> Link URL: </td>
    <td> <input type="text" name="linkurl[]" value=""> </td>
    </tr>
    <tr>
    <td> Link Description: </td>
    <td> <textarea name="linkdesc[]" cols="50" rows="5" onclick="this()=''"></textarea> </td>
    </tr>

    </table>
    </div>
    </div>

    ***MY QUESTION IS, HOW TO REMOVE FIELDS THAT WERE ADDED, I WANT TO ADD A REMOVE BUTTON ON IT.

    Thanks in advance guys! Im new here, Your reply is highly appreciated, currently im stuck here in this script.
     
    jackjones010101, Jul 21, 2010 IP