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>
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.
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.
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.
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...