• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

adding and deleting a row in html

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have certaing heading in a table and above that table there is link .

My Requirement is : if a click on the link a new row should be craeted automatically with all the input box and other options in the row.

and if the particular row is checked ,the row is deleted.

can any body plase help me how to implement this....or any mataerial where i can get some help.

Thanks
Regards
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rammie singh wrote:i have certaing heading in a table and above that table there is link .

My Requirement is : if a click on the link a new row should be craeted automatically with all the input box and other options in the row.

and if the particular row is checked ,the row is deleted.

can any body plase help me how to implement this....or any mataerial where i can get some help.

Thanks
Regards



to delete rows
the script is as:

function deleteRows(rowObjArray)
{
if (hasLoaded) {
for (var i=0; i<rowObjArray.length; i++) {
var rIndex = rowObjArray[i].sectionRowIndex;
rowObjArray[i].parentNode.deleteRow(rIndex);
}
}
}


call in html page

<input type="button" value="Delete [D]" onclick="deleteChecked();" />
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rammie,
i had a requirement like this in one of my projects.
i can suggest two methods:
1) get a reference to the last row and use cloneNode.
something like : pass the ref to the last node from where you are calling the method
function addRow(key){

document.getElementById("YourTable").appendChild(key.cloneNode(true));

}



2) Its pretty easy - first you add the row to the table and then create the cells and add them to your newly created row. refer to the following code and tell me if this works for you.
 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have tried somthing like this.....




but this code has some problem.
first : it has serial number for each rows. but when we delete the row and again add a row it starts from the same previous row serial number .foe example

i have added 1 ,2 , 3, 4 rows.
now i delete 3 rd row then next row would be again 4th. and hence index no 4 is repeated...and so on.

can any one please tell me where the problem is.

second also i don't require this index in my code. what can i do to remove this index.

Thanks
Regards
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are looking at the number of rows. The HTML has no clue you deleted a row. If you want the number to increase, you need to keep a counter and not read the length.

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic