Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: "object expected" error


Message #1 by "Amit Andersen" <amit@a...> on Wed, 27 Mar 2002 12:02:46
<html><div style='background-color:'><DIV>
<P><BR><BR></P>
<DIV>
<DIV></DIV>
<P>Hi Amit,</P></DIV>
<P>&nbsp;What you are doing is correct, but there is no such built in function. You need to write that function on your
own.</P></DIV>
<P>&nbsp;Here I am giving the complete code for you with that function. I hope this will help you to get rid of the error
what you are getting </P>
<DIV></DIV>
<P>--------------------------------------------------------------------------------------------</P>
<DIV></DIV>
<P>&lt;script language="javascript"&gt;</P>
<DIV></DIV>
<P>&lt;!--</P>
<DIV></DIV>function count_long_words(str) 
<DIV></DIV>
<DIV></DIV>{ 
<DIV></DIV>
<DIV></DIV>var count = 0; 
<DIV></DIV>
<DIV></DIV>var countSix = 0; 
<DIV></DIV>
<DIV></DIV>var length = str.length; 
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>for (i=0 ; i &lt; length ; i++) { 
<DIV></DIV>
<DIV></DIV>var chrAt = str.charAt(i); 
<DIV></DIV>
<DIV></DIV>if ((chrAt == ' ') &amp;&amp; (countSix &gt; 6)) { 
<DIV></DIV>
<DIV></DIV>countSix = 0; 
<DIV></DIV>
<DIV></DIV>count++; 
<DIV></DIV>
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>else { 
<DIV></DIV>
<DIV></DIV>if (chrAt == ' ') { 
<DIV></DIV>
<DIV></DIV>countSix = 0; 
<DIV></DIV>
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>if (isLetterOrDigit(chrAt)) { 
<DIV></DIV>
<DIV></DIV>countSix++; 
<DIV></DIV>
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>return count; 
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<P>} </P>
<DIV></DIV>
<P>function isLetterorDigit (c) {</P>
<DIV></DIV>
<P>&nbsp;return ( isLetter(c) || isDigit(c) );</P>
<DIV></DIV>
<P>}</P>
<DIV></DIV>
<P>function isDigit (c) {</P>
<DIV></DIV>
<P> return ( (c &gt;= "0") &amp;&amp; (c &lt;= "9"));</P>
<DIV></DIV>
<P>}</P>
<DIV></DIV>
<P>function isLetter (c) {</P>
<P>&nbsp; return ( (( c &gt;= "a") &amp;&amp; (c &lt;= "z")) || (( c &gt;= "A") &amp;&amp; (
c&gt;= "z")) );</P>
<P>}</P>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>//--&gt;</DIV>
<DIV>------------------------------------------------------------------------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>Wish you all the best</DIV>
<DIV>Have a good day.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks &amp; Best Regards</DIV>
<DIV>Veera R Ponna</DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a
href='http://g.msn.com/1HM303401/y'>http://explorer.msn.com</a>.<br></html>

  Return to Index