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 14 of 14
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Creating a ...Loading text on textarea

    I have a textarea with a ton of text in it. Once you visit the page with all the text it takes the page a min. to load all the text into the textarea box. Is there a way I can have the textarea box say ...Loading Please Wait until the complete text is loaded and then show all the text?

    Thanks

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vapor
    I have a textarea with a ton of text in it. Once you visit the page with all the text it takes the page a min. to load all the text into the textarea box. Is there a way I can have the textarea box say ...Loading Please Wait until the complete text is loaded and then show all the text?

    Thanks
    var LotsOfText = "whatever your text is, and how you load it. I would assume JS?";
    document.form.textarea.value = "Loading Please Wait......";
    document.form.textarea.value = LotsOfText;
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    HideWait(){
     
    document.getElementById('mess').style.visibility='hidden';
    }

    //-->
    </script>

    </head>

    <body onload="HideWait();" >

    <span id="mess" >Please Wait</span>
    <textarea name="" rows="50" cols="100">Ton of Text</textarea>
    </body>
    </html> 

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Where?

    How would I stick that function in this code to make it work?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title></title>
        <style type="text/css">
          .highlight {
            background-color:yellow;
            }
        </style>
        <script type="text/javascript">
          function searchText(){
            var str=document.getElementById('srch_str').value;
            var old_str=document.getElementById('txt').value;
            var regex=new RegExp('('+str+')','ig');
            
            var new_str=old_str.replace(regex,'<span class="highlight">$1</span>') ;
            if(new_str.length==old_str.length){
              new_str="No Match Found!";
              }
            document.getElementById('results').innerHTML=new_str;
            }
        </script>
      </head>
      <body>
        <form onsubmit='searchText();return false'>
          Search: <input type="text" id="srch_str" /> 
          <input type="submit" value="Find Text"/>
          <br />
          <textarea cols="40" rows="5" id="txt">Hello all.  I am testing a search function. It is because of this that this text is here.
          </textarea>
        </form>
        Results:
        <div id="results">
        </div>   
      </body>
    </html>

  • #5
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this code.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title></title>
    <style type="text/css">
    .highlight {
    	background-color:yellow;
    }
    </style>
    <script type="text/javascript">
    function init(){
    	// Code for EXAMPLE PURPOSES
    	var html='';
    	for(var i=1; i<=1500; i++){
    		html+='Hello all.  I am testing a search function. It is because of this that this text is here.\n';
    	}
    	// END OF EXAMPLE CODE	
    	var myTXT = document.getElementById('txt');
    	myTXT.value=html;
    }
    function searchText(){
    	document.getElementById('results').innerHTML="Loading Results...";
    	stTO = window.setTimeout("st()",10);
    }
    function st(){
    	var str=document.getElementById('srch_str').value;
    	var old_str=document.getElementById('txt').value;
    	var regex=new RegExp('('+str+')','ig');
    	
    	var new_str=old_str.replace(regex,'<span class="highlight">$1</span>') ;
    	if(new_str.length==old_str.length){
    		new_str="No Match Found!";
    	}
    	document.getElementById('results').innerHTML=new_str;
    	return;
    }
    </script>
    </head>
    <body onload="setTimeout('init()',10)">
    	<form onsubmit='searchText(); return false'>
    		Search: <input type="text" id="srch_str" /> 
    		<input type="submit" value="Find Text"/>
    		<br />
    		<textarea cols="40" rows="5" id="txt">Loading Content....</textarea>
    	</form>
    	Results:
    	<div id="results"></div>   
    </body>
    </html>
    Last edited by rlemon; 05-26-2005 at 06:03 PM.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #6
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    please help

    My code got screwed up in the process of transfering codes to gether and I am confused! here is my code:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title></title>
        <style type="text/css">
          .highlight {
            background-color:yellow;
            }
        </style>
        <script type="text/javascript">
          function searchText(){
            var str=document.getElementById('srch_str').value;
            var old_str=document.getElementById('txt').value;
            var regex=new RegExp('('+str+')','ig');
            
            var new_str=old_str.replace(regex,'<span class="highlight">$1</span>') ;
            if(new_str.length==old_str.length){
              new_str="No Match Found!";
              }
            document.getElementById('results').innerHTML=new_str;
            }
        </script>
      </head>
      <body>
        <form onsubmit='searchText();return false'>
          Search: <input type="text" id="srch_str" /> 
          <input type="submit" value="Find Text"/>
          <br />
          <textarea cols="40" rows="5" id="txt">Hello all.  I am testing a search function. It is because of this that this text is here.
          </textarea>
        </form>
        Results:
        <div id="results">
        </div>   
      </body>
    </html>
    Using the code above, how can I make the ...Loading Please Wait text appear in the textarea when loading. I need to work it into this code, I cant just use the code that rlemon gave me. Sorry. I need to work it into the above code.

    Thanks

  • #7
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why can you not use my code?

    ohh well.

    Here is another one.

    Works fine,
    uses your code (with a few modifications)

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title></title>
        <style type="text/css">
          .highlight {
            background-color:yellow;
            }
        </style>
        <script type="text/javascript">
    	  function init(){
    	  var ta = document.getElementById('txt');
    	  ta.value = "Hello all.  I am testing a search function. It is because of this that this text is here."
    	  }
    	  function setLoading(){
    	  var ta = document.getElementById('results');
    	  ta.innerHTML = "Loading Please Wait......"
    	  return;
    	  }
          function searchText(){
            var str=document.getElementById('srch_str').value;
            var old_str=document.getElementById('txt').value;
            var regex=new RegExp('('+str+')','ig');
            
            var new_str=old_str.replace(regex,'<span class="highlight">$1</span>') ;
            if(new_str.length==old_str.length){
              new_str="No Match Found!";
              }
            document.getElementById('results').innerHTML=new_str;
            }
        </script>
      </head>
      <body onload="setTimeout('init()', 500)">
        <form onsubmit='setTimeout("searchText()", 500);return false'>
          Search: <input type="text" id="srch_str" /> 
          <input type="submit" value="Find Text" onclick="setLoading()"/>
          <br />
          <textarea cols="40" rows="5" id="txt">Loading Please Wait......
          </textarea>
        </form>
        Results:
        <div id="results">
        </div>   
      </body>
    </html>
    tested in IE, Mozilla, and FireFox
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #8
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here is an example with the textfield 'disabled'

    http://www.rlemon.com/scripts/search/index2.html

    (i.e the user cannot make changes to the text, the text is loaded through JS and if they make a change it gets reverted onFocusOut
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #9
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Thanks man

    I REALLY appreciate it!

  • #10
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    rlemon

    I really appreciate your help with this code. the problem is that the code I use allows me to hit enter (make a new paragraph) within the textarea and it will show up in the textarea on the site when it loads.

    The code you gave me (which I really want to use) wont let me hit enter. If you do, the page has an error when it loads and I can not view the text in the textarea.

    Is there a way to modify the code that you posted to allow returns in the body of the text?

    Thank you so much

    -vapor

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,045
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Put \n where you want to make a newline.

    ta.value = "Line 1\nLine 2\nLine 3"

  • #12
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv is correct.

    in your code where you load your textarea text place '\n' where ever you want a line break.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #13
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rlemon
    here is an example with the textfield 'disabled'

    http://www.rlemon.com/scripts/search/index2.html

    (i.e the user cannot make changes to the text, the text is loaded through JS and if they make a change it gets reverted onFocusOut
    ohh and i forgot to post how i made the textarea 'non-changable'

    to the textarea append the attibute:

    onchange="init()"
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #14
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Ahhh, much better. The text in the textarea looks much neater.

    Thank you!


  •  

    Posting Permissions

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