I want to stop find() method when it got end of document...

Discussion in 'JavaScript' started by yogeshmca, Nov 6, 2008.

  1. #1
    Hi all

    I am implementing a search functionality using find() method. I am calling the findString() method on the button click and I have two check boxes : one for case sensitive search and another for search wrap.

    The code is as below:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="JavaScript">
    <!--
    var TRange=null

    function findString (str) {

    var cs = document.getElementById("case");
    var wr = document.getElementById("wrap");

    var strFound;
    var csb = false;
    if(cs.checked){
    csb = true;
    }

    self.find(str,csb,false);

    }
    //-->
    </script>
    </head>

    <body>
    <table width="488" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="488"><div id="str123"><p>There are browser dependant ways, example using CSS extensions for<br />
    Mozilla/Netscape and using script for IE5+:</p>
    <p>&nbsp;</p>
    <p>There are browser dependant ways, example using CSS extensions for<br />
    Mozilla/Netscape and using script for IE5+:</p>
    <p>&nbsp;</p>
    <p>There are browser dependant ways, example using CSS extensions for<br />
    Mozilla/Netscape and using script for IE5+:</p></div></td>
    </tr>
    </table>

    <form name="f1" action=""
    onSubmit="if(this.t1.value!=null && this.t1.value!='')
    findString(this.t1.value);return false"
    >
    <input type="text" name=t1 value="" size=20>
    <input type="submit" name=b1 value="Find"><Br />
    <input id="case" type="checkbox"> Case Sensitive</input><br />
    <input id="wrap" type="checkbox"> Wrap </input><br />
    </form>
    </body>
    </html>


    the code is working fine but I am not able to do the wrap searching. I wants when I check the wrap search check box , the search will start from begin if it is in and if not checked then it stop in the end of the document.

    Thanks in advance!
     
    yogeshmca, Nov 6, 2008 IP