hi,
here is my problem-
i am creating a table dynamically using java script- the number of cells in a row is constant and the data is accepted from the user from x text boxes(based on number of cells).

now, i want to insert a button in the x+1th cell of each row
and i want to extract the data in the row that contains the button that gets clicked back into the text boxes for editing.

how do i go about doing this? dynamically creating the table is not a problem, but am not able to extract the row data for editing :-(
i forgot to mention this- but after editing the data in the text box, i need to be able to insert the data back into the same row from which the data was extracted in the first place...

To answer your question, first obtain a reference to your table. If you have your table an id: <table id='MyTable'>...</table> then use var t = document.getElementById('MyTable') to obtain a reference to the table. Since 't' now holds a reference to the table, then assuming you are interested in the x+1th CELL (where X is 0) of row 0 then alert(t.rows[0].cells[1].innerHTML) should show you the html in that cell.

On another note, based on your description, it sounds like you want/need an inline editor. I suggest you look at either of these:
http://www.appelsiini.net/projects/jeditable (the demo is at http://www.appelsiini.net/projects/jeditable/default.html)

http://code.google.com/p/jquery-in-place-editor/ (the demo is at http://jquery-in-place-editor.googlecode.com/svn/trunk/demo/index.html)

that helped a lot-
thanks man :-D

You are welcome!

hi, I am also working on dynamically adding table row using jsp, but i am getting one exception in that : whenever in a table there is only one row and i submit, it trough's an error , but works fine when i add row that means when there's total 2 row in a table.
can anybody help me resolve this issue ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.