Jump to content

How to get the content of a table rows and columns


lilmer
 Share

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 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);
                                                });
                                            }
                                        });
                            
                          });
                        
                        
                        
                    });
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

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