lilmer Posted March 4, 2013 Share Posted March 4, 2013 Can anyone give me an idea on how I will count the table column and table row and get the id, attribute and the content of a each cell (the cell is contenteditable). What tools i have to use. e.g. <table id='sheet'> <tbody> <tr> <td id='1A' rowspan=2>Rowspan 2</td> <td id='1B'>22222</td> <td id='1C'>33333</td> </tr> <tr> <td id='2B' colspan='2'> Colspan2</td> </tr> <tr> <td id='3A' style='color:red'>Whaterver</td> <td id='3B' style='font-weight:bold'>Askyourmother</td> <td id='3C'>sigh</td> </tr> </tbody> </table> I'm using PHP and Jquery(Javascript). Thanks. . Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/ Share on other sites More sharing options...
trq Posted March 4, 2013 Share Posted March 4, 2013 Do you need this done client side or server side? Even though you posted in PHP help you mention jQuery so your intention is not at all clear. Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/#findComment-1416424 Share on other sites More sharing options...
lilmer Posted March 4, 2013 Author Share Posted March 4, 2013 Oh sorry bout that, what will happen is if I've got the content and attribute of each cell it will pass the value to a PHP function then print it out. So sorry if I posted it here. Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/#findComment-1416428 Share on other sites More sharing options...
trq Posted March 4, 2013 Share Posted March 4, 2013 Server side then, you'll want to look at the DOM extension. http://php.net/dom Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/#findComment-1416431 Share on other sites More sharing options...
lilmer Posted March 4, 2013 Author Share Posted March 4, 2013 Okay thank you Mr. Administrator! What I want is solved! $('#sheet tr').each(function(){ // alert($(this).attr('id')); $(this).find('td').each(function(){ var content = $(this).text(); //do whatever you want with the text var tdid = $(this).attr('id'); var style = $(this).attr('style'); $.ajax({ type: "POST", url: "function.php", data: { 'id' : tdid, 'content': content }, dataType: "text", success: function(msg){ $("#output").append(function(){ $("#output").html(msg); }); } }); }); }); Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/#findComment-1416437 Share on other sites More sharing options...
trq Posted March 4, 2013 Share Posted March 4, 2013 Awesome. Link to comment https://forums.phpfreaks.com/topic/275215-how-to-get-the-content-of-a-table-rows-and-columns/#findComment-1416441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.