469,330 Members | 1,285 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Adding rows to a table by javascript

6
Hi

I want to Query a database using AJAx and display the results in the middle rows of an existing table. right now the server builds rows and return them to the main page, but I don't know how to insert them to the right spot.
basically, I look for a function he inserts a string before /after some row in the table .

in the pad I have:
<table>
<tr><td>Header</td></tr>
<tr><td>footer</td></tr></table

I have a string : "<tr><td>Result 1</td></tr>" I want to insert between the Header and the footer using Javascript. How can I do it? [I get this string from the server].

Thanks
Yuval
Mar 25 '08 #1
4 1404
hsriat
1,654 Expert 1GB
This example may help you.
Mar 25 '08 #2
yuvaly
6
Thank you, but this example uses Insert Row, that means I have to read the content of the response I get from the server to know whar rows/collums to insert, when in the server they already formatted it so I can just insert it...I want to insert a whole string [that represents several rows] into the table between the two rows.
Mar 26 '08 #3
hsriat
1,654 Expert 1GB
Thank you, but this example uses Insert Row, that means I have to read the content of the response I get from the server to know whar rows/collums to insert, when in the server they already formatted it so I can just insert it...I want to insert a whole string [that represents several rows] into the table between the two rows.
That is not possible I guess. Instead sending the whole string from the server, send tokenized string (with all the fields and rows saperated by token eg. a pipe |). And on the front, split() it and add the rows at required positions.
Mar 26 '08 #4
iam_clint
1,208 Expert 1GB
you can do table.innerHTML = table.innerHTML+MyOtherVar;

However this is not standard and may not work on some browsers properly.
Mar 26 '08 #5

Post your reply

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

Similar topics

7 posts views Thread by jon | last post: by
3 posts views Thread by Jim Heavey | last post: by
3 posts views Thread by didi86 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.