Jump to content

How to get the content of a table rows and columns


lilmer

Recommended Posts

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. .

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);
                                                });
                                            }
                                        });
                            
                          });
                        
                        
                        
                    });

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.