Results 1 to 5 of 5

Thread: how to ensure that the Typewrite message DO NOT appear in textbox?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    how to ensure that the Typewrite message DO NOT appear in textbox?

    i want this text: "The best way to learn, is to study examples. -www.W3Schools.com" NOT TO appear in a textbox. but i dunno how to do it. i want the text to appear as label form. i have tried to use <label> tag, but to no avail. the textr will appear in a browser but there will be no effect on the text.


    can someone show me??

    this are the codes that i am currently using. i get the codes from w3schools.
    <html>
    <head>

    <script type="text/javascript">
    message="The best way to learn, is to study examples. -www.W3Schools.com"
    pos=0
    maxlength=message.length+1

    function writemsg()
    {
    if (pos<maxlength)
    {
    txt=message.substring(pos,0)
    document.forms[0].msgfield.value=txt
    pos++
    timer=setTimeout("writemsg()", 50)
    }
    }
    function stoptimer()
    {
    clearTimeout(timer)
    }
    </script>
    </head>

    <body onload="writemsg()" onunload="stoptimer()">
    <form>
    <input id="msgfield" size="65">
    </form>
    </body>
    </html>

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to ensure that the Typewrite message DO NOT appear in textbox?

    W3Schools has some good tutorials, but their examples are usually awful, and this is no exception. Throw that one away.

    The key to DOM scripting using Javascript is to first create/envision the end result in HTML alone. Then, create it using Javascript.

    If you've never done DOM programming before, start with the MDC DOM reference.

    Also, please use the [code] or [highlight] tags to post code.

  3. #3
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    372

    Re: how to ensure that the Typewrite message DO NOT appear in textbox?

    Quote Originally Posted by twinkie
    i want this text: "The best way to learn, is to study examples. -www.W3Schools.com" NOT TO appear in a textbox. but i dunno how to do it. i want the text to appear as label form. i have tried to use <label> tag, but to no avail. the textr will appear in a browser but there will be no effect on the text.


    can someone show me??

    this are the codes that i am currently using. i get the codes from w3schools.
    <html>
    <head>

    <script type="text/javascript">
    var txtElm=document.getElementById("txt")
    message="The best way to learn, is to study examples. -www.W3Schools.com"
    pos=0
    maxlength=message.length+1

    function writemsg()
    {
    if (pos<maxlength)
    {
    txt=message.substring(pos,0)
    txtElm.innerHTML=txt
    pos++
    timer=setTimeout("writemsg()", 50)
    }
    }
    function stoptimer()
    {
    clearTimeout(timer)
    }
    </script>
    </head>






    <body onload="writemsg()" onunload="stoptimer()">
    <div id="txt" name="txt" ></div>
    </body>
    </html>


    here you go. i used a div, but i guess you could use a label tag, though those are usually for labeling form inputs.

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Re: how to ensure that the Typewrite message DO NOT appear in textbox?

    i have tried using the code, but it does not work. instead they highlighted this code: <body onload="writemsg()" onunload="stoptimer()">. the error they give is that it is an invalid markUp and that the DIV tag is not supported.

  5. #5
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    372

    Re: how to ensure that the Typewrite message DO NOT appear in textbox?

    Quote Originally Posted by twinkie
    i have tried using the code, but it does not work. instead they highlighted this code: <body onload="writemsg()" onunload="stoptimer()">. the error they give is that it is an invalid markUp and that the DIV tag is not supported.
    i had changed your output code so you could use a div.
    i didn't notice there was a bigger problem at hand;
    the script is trying to refer to a body that doesnt exist.



    try this:

    Code:
    <html>
    <head>
    
    
    </head>
    
    
    <body onload="writemsg()" onunload="stoptimer()">
    
    <div id="txt" name="txt" ></div>
    
    <script type="text/javascript">
    var txtElm=document.getElementById("txt")
    message="The best way to learn, is to study examples. -www.W3Schools.com"
    pos=0
    maxlength=message.length+1
    
    function writemsg()
    {
    if (pos<maxlength)
    {
    txt=message.substring(pos,0)
    txtElm.innerHTML=txt
    pos++
    timer=setTimeout("writemsg()", 50)
    }
    }
    function stoptimer()
    {
    clearTimeout(timer)
    }
    </script>
    </body>
    </html>

    you can also use marquee tags...

Posting Permissions

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



Click Here to Expand Forum to Full Width