Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
adding dynamic table rows

Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
New one
New one

Joined: 06 Dec 2006
Posts: 1

PostPosted: Wed Dec 06, 2006 6:40 pm    Post subject: adding dynamic table rows Reply with quote

I am trying to add new rows to a table using ajax. I have the following javascript function for adding the row, but I need to get the data for the cells using AJAX (instead of the static 'data1-9'):

function addOrderLine(){
var tbl = document.getElementById('mytable'); var lastRow = tbl.rows.length; var row = tbl.insertRow(lastRow); arr= new Array('data1','data2','data3','data4','data5','data6','data7','data8','data9'); for (r = 0; r < arr.length; r++) { var cell = row.insertCell(r); cell.innerHTML = arr[r]; }

I need data1-9 to be more complicated. I need the cells to contain various html elments including dynamically generated dropdown menus.


arr= new Array('<select name=\"select\"><option value=\"val1\">val1</option><option value="val2">val2</option></select>', 'data2', etc. );

...but only more complicated, and with serverside generated options.

I am hoping to run some ajax to get the HTML for each cell but I'm not sure how to get the html for each cell seperately...

I'm quite new to AJAX, but so far it seems to me that I have basically two options when getting data: 1) return HTML 2) return XML.

If I return HTML, I can just dump this into the cell with as many bells and whistles as I like. However, I can't work out how I would seperate the data for each of the cells unless I do 9 seperate http requests to 9 seperate pages for the 9 seperate cells.

If I return XML, I can seperate data for each of the cells by using seperate xml tags, however, I can't just dump html inside the XML elements because it will mess up the xml. Does this mean that I have to have seperate xml tags for every bit of data in the html (eg seperate xml tags for every option in the dropdown)? Isn't it gonna be a bit messy trying to convert all these xml tags to create the HTML...

I'm sure there must be a simple answer, but because I'm a bit new to AJAX, I'm not aware of all the options.

Any thoughts or things that I can look into are welcome. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 XML & Copyright Notice 

Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X

Link to our site:


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos

Normal Bookmark

Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax

Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?

it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert