Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    read contents of table cell

    Hi all. Is it possible to read the contents of a table cell. I have the below table and would like extract the value of the first cell. The first cell will always be a hyperlink so I guess I only need the contents between the "<A>" tags. So the first row should return ""434235". How can I do this.

    Code:
      <table width=100% align=center border=0 cellspacing=2 cellpadding=2> 
             <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=00328">434235</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">john
                      riley</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0008</font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">FARMLAND</font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">03-02-2009</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="05-11-2009" ></font></td> 
                    </tr> 
                    
            <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=07056">2233556</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">JEFF
                      COOK</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0001</font></td> 
                    <td align=left><font size=1 face="Verdana,Arial,Geneva">NEW JERSEY&nbsp;             </font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">02-02-2009</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="06-08-2009" ></font></td> 
                    </tr> 
                    
            <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=07605">232344</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">FRANK
                      COOK</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0025</font></td> 
                    <td align=left><font size=1 face="Verdana,Arial,Geneva">ROANOKE                        </font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">06-27-2011</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="08-10-2009" ></font></td> 
                    </tr> 
                    
    </table>

  • #2
    New Coder
    Join Date
    May 2005
    Location
    Cebu, Philippines
    Posts
    46
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Hi, Try This One:

    Code:
    
     <table id='tbl' width=100% align=center border=0 cellspacing=2 cellpadding=2> 
             <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=00328">434235</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">john
                      riley</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0008</font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">FARMLAND</font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">03-02-2009</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="05-11-2009" ></font></td> 
                    </tr> 
                    
            <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=07056">2233556</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">JEFF
                      COOK</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0001</font></td> 
                    <td align=left><font size=1 face="Verdana,Arial,Geneva">NEW JERSEY&nbsp;             </font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">02-02-2009</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="06-08-2009" ></font></td> 
                    </tr> 
                    
            <tr> 
                  <td align=center><font size="1" > 
                    <a href="Display?new=07605">232344</a></font></td> 
                    <td align=left><font size="1" face="Verdana,Arial,Geneva">FRANK
                      COOK</font> 
                    </td> 
                   <td align=center><font size=1 face="Verdana,Arial,Geneva">0025</font></td> 
                    <td align=left><font size=1 face="Verdana,Arial,Geneva">ROANOKE                        </font></td> 
                    <td align=center><font size=1 face="Verdana,Arial,Geneva">06-27-2011</font></td> 
                    <td align=center><font size=-1 face="Verdana,Arial,Geneva"> 
                    <input type=text size=10 maxlength=10 name="new" value="08-10-2009" ></font></td> 
                    </tr> 
                    
    </table>
    
    <script type='text/javascript' language='javascript'>
    	var objTbl = document.getElementById('tbl');
    	var data = "";
    	
    	for (i=0; i < objTbl.rows.length; i++)
    	{
    		var tmpCell = objTbl.rows[i].cells[0];		
    		var tmpContent;
    		
    		if (tmpCell.innerText)
    			tmpContent = tmpCell.innerText;
    		else
    			tmpContent = tmpCell.textContent;
    			
    		if (tmpContent != "undefined")
    		{
    			data += "Row " + (i+1) + " Cell 1 = " + tmpContent + "\n\r";
    		}
    	}
    	
    	alert (data);
    	
    </script>

  • #3
    New Coder
    Join Date
    May 2005
    Location
    Cebu, Philippines
    Posts
    46
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Code:
    <script type='text/javascript' language='javascript'>
    	var objTbl = document.getElementById('tbl');
    	var data = "";
    	
    	for (i=0; i < objTbl.rows.length; i++)
    	{
    		var tmpCell = objTbl.rows[i].cells[0];		
    		var tmpContent;
    		
    		if (tmpCell.innerText)
    			tmpContent = tmpCell.innerText;
    		else
    			tmpContent = tmpCell.textContent;
    			
    		if (tmpContent != "undefined")
    		{
    			data += "Row " + (i+1) + " Cell 1 = " + tmpContent + "\n\r";
    		}
    	}
    	
    	alert (data);
    	
    </script>

  • Users who have thanked JygzIsHere for this post:

    nikko50 (05-30-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •