By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

How to insert a row dynamically in a table which already exists in the page?

100+
P: 129
Hello friends,
What my doubt is, a page is already designed in that page a table exists, and i am doing a script like a radio button exixts and when click that radio button some function is called and in that function i want to create a extra row in that table which already exists on page. That is my problem.

How to insert a row dynamically in a table which already exists in the page?
Nov 11 '08 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
You can use the insertRow() method.

PS. please use a good thread title. I've changed it to better describe the problem.
Nov 11 '08 #2

100+
P: 129
Thank you my friend i change how to put better title for questions.
But can you help me with some sample code.

Ok i got the sample code but it inserts a row on top of the table, but i want to add a row in middle of table i.e after some fields.
Nov 11 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Use the index to add the row at the specified position, e.g. insertRow(2) would add above the third row.
Nov 11 '08 #4

100+
P: 129
Hai friend,
Thanks for helping me but one another doubt if i want to modify a column of a row already existed in the table, how to do this? Is there any function like selectRow etc.....
Nov 12 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Once you have the row, use the the cells[] array to get the cells within a row and use the index to get the column you're after. To modify it, you can simply use its innerHTML property.
Nov 12 '08 #6

100+
P: 129
Thank you my friend its working. Thank you.
Nov 12 '08 #7

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad to help :)
Nov 12 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.