SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to delete added rows ??

    Hello forums !!
    I had used the following javascript code for adding rows
    Code:
    function addRow(row)
    {
    	table = row.parentNode.parentNode;
    	pos = row.rowIndex;	
    	
    	// Row for file
    	k = 0;
    	row = table.insertRow(pos);
    	cell = row.insertCell(k++);
    	//cell.setAttribute('align','right');	
    	cell.innerHTML = 'File Upload';
    	cell = row.insertCell(k++);	
    	cell.innerHTML = '<input type="text" name="title[]" class="text" />';	
    }
    for event handling
    Code:
    <input class="text" type="button" name="add" value="add more &raquo;" onclick="addRow(this.parentNode.parentNode)" />
    I want to make some change with the function.
    I want to add a function that deletes the row created by js
    how to perform such ?
    Please help me. Any help and suggestions will be highly appreciated.
    Thank you

  2. #2
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand correctly, just change your addRow function to deleteRow.

    Code:
    function removeRow(row) {
                    table = row.parentNode.parentNode;
                    pos = row.rowIndex;
                    
                    k = 0;
                    row = table.deleteRow(pos);
                }
    or r u asking for a way to delete the created row specifically?
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.


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
  •