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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search in Textarea only....Script..needed

    Hi
    as you can see this is a search in page script
    but , i want to know if it can be re-edited so
    that when I look for a word or letter the script would only search
    in the Textarea only not out side of it




    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var NS4 = (document.layers);var IE4 = (document.all);var win = this;var n = 0;
    function findInPage(str) {var txt, i, found;if (str == "")return false;if (NS4) {
    if (!win.find(str))while(win.find(str, false, true))n++;elsen++;
    if (n == 0) alert(str + " was not found on this page.");}if (IE4) {
    txt = win.document.body.createTextRange();for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {txt.moveStart("character", 1);txt.moveEnd("textedit");}if (found) {
    txt.moveStart("character", -1);txt.findText(str);txt.select();txt.scrollIntoView();n++;
    }else {if (n > 0) {n = 0;findInPage(str);}else
    alert(str + " was not found on this page.");}}return false;}
    // End -->
    </script>
    </HEAD>

    <BODY>






    <form name=search>
    Find in Page
    <input name=string type=text size=15 onChange="n = 0;">
    <input type=button value="Search"
    onClick="findInPage(this.form.string.value);">
    </form>




    <form NAME="copy">


    <textarea NAME="txt" ROWS=5 COLS=25 WRAP=VIRTUAL>
    one two three four</textarea>
    </form>

    one two three four

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    txt = win.document.body.createTextRange();

    try changing it to this

    txt = win.document.FormName.ElementName.createTextRange();

  • #3
    New Coder
    Join Date
    Dec 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I worked (tahnks)

    That works just fine


    Thanks,

  • #4
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this script is great. can anyone point me in the right direction for how to modify this to work in firefox?


  •  

    Posting Permissions

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