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

add rows to table from an ajax response

P: 1
In my first php file I have a table with multiple rows and form fields. When the user selects a category I call a second php file which returns new rows (<tr>) which have to be added to the table from the first php file:
Expand|Select|Wrap|Line Numbers
  1. <select name="in[catid]" style="width:200px;" id="categorie" onchange="getSubCat(this,0)"> <?=$optioncat?></select>
  2.  
the function getSubCat calls a php file using ajax and the result is set to innerhtml of div "result"
Expand|Select|Wrap|Line Numbers
  1. var e = document.getElementById('result'); 
  2.     e.innerHTML = ajax.response;
  3.  
How to correctly add those new rows to the table ?
Jul 25 '08 #1
Share this Question
Share on Google+
1 Reply


hsriat
Expert 100+
P: 1,654
Instead of using the innerHTML function, first add rows to the table by insertRow and then cells to the rows by insertCell. Then with that cell object, use innerHTML to insert data into that cell.
Jul 27 '08 #2

Post your reply

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