|
-
Mar 15th, 2007, 11:13 PM
#1
Thread Starter
Member
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>
-
Mar 17th, 2007, 02:48 AM
#2
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.
-
Mar 19th, 2007, 08:25 PM
#3
Hyperactive Member
Re: how to ensure that the Typewrite message DO NOT appear in textbox?
 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.
-
Mar 22nd, 2007, 02:25 AM
#4
Thread Starter
Member
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.
-
Mar 22nd, 2007, 04:47 AM
#5
Hyperactive Member
Re: how to ensure that the Typewrite message DO NOT appear in textbox?
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|