Web Design and Development Forums

using ajax to add table row

This is a discussion on "using ajax to add table row" within the XML, RSS & Atom section. This forum, and the thread "using ajax to add table row are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > XML, RSS & Atom

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Dec 6th, 2006, 12:20   #1 (permalink)
Junior Member
 
Join Date: May 2005
Location: bath - england
Posts: 44
using ajax to add table row

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)':

Code: Select all
 
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.

eg

Code: Select all
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!
simonneaves is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Dec 6th, 2006, 13:23   #2 (permalink)
Elite Veteran
 
Daniel's Avatar
 
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,381
Blog Entries: 12
Send a message via MSN to Daniel
Re: using ajax to add table row

Sorry - cant help - Always thought Ajax was a football team!
__________________
FMFA Manager / World Footy Forums
Daniel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Dec 7th, 2006, 23:15   #3 (permalink)
 
JacobHaug's Avatar
 
Join Date: Dec 2005
Location: On Internet
Posts: 5,550
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
Re: using ajax to add table row

hahaha...lol
__________________
JacobHaug.com - My Portfolio
JacobHaug is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Dec 8th, 2006, 23:39   #4 (permalink)
 
Ryan Fait's Avatar
 
Join Date: May 2006
Location: Las Vegas
Posts: 4,028
Re: using ajax to add table row

Haha

Google is your friend: http://www.sitepoint.com/article/remote-scripting-ajax
__________________
CSS Sticky Footer | Moojoo's CSS Layouts | ryanfait.com
Ryan Fait is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
ajax

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX Help alexgeek JavaScript Forum 3 Oct 16th, 2007 07:04
Ajax Messages (Ajax Demonstration) iMarc JavaScript Forum 1 Mar 21st, 2007 22:48
PHP AJAX HOW-TOs nuk PHP Forum 1 Jan 5th, 2007 15:29
CSS and AJAX magicmarc CSS Forum 7 Aug 6th, 2006 13:21
Need to align width of Float table with the table below Vertabase CSS Forum 4 Mar 8th, 2006 21:21



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 16:20.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59