Jump to content

How to get the content of a table rows and columns


Go to solution Solved by 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. .

  • Solution

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);
                                                });
                                            }
                                        });
                            
                          });
                        
                        
                        
                    });
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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