Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting text in table cells

Status
Not open for further replies.

phentalmyst

Programmer
Jan 30, 2001
18
US
hi folks,

i have a table cell that im wanting to keep track of the innerText of, and the code i wrote isnt working properly. i dont think im referencing the text accurately and havent been able to find the solution.

here's my code:

<html>

<head>
<title>New Page 1</title>
<script language=&quot;javascript&quot;>
<!--

function checkHeight(){
if(document.all.test.innerText > 2){document.write (&quot;YAY&quot;)
} else {document.write (&quot;sorry, try again&quot;)}
}
//-->
</script>
</head>

<body onLoad=&quot;checkHeight()&quot;>

<center>
<table id=&quot;test&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;200&quot;>
<tr>
<td>kjasdlfkj<br>
Asdf<br>
asdf<br>
Asdf<br>
Asdf</div></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</center>

</body>

</html>


what's supposed to happen is if there's more than 2 characters of text in the cell, you get a YAY doc-write, but if not, you get a SORRY doc-write.

any suggestions?

thanks!
 

...if(document.all.test.innerText.length > 2){...
b[sup]2[/sup] - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top