How to start a marquee with JavaScript based on user input?
Posted
by APShredder
on Stack Overflow
See other posts from Stack Overflow
or by APShredder
Published on 2010-03-18T01:23:13Z
Indexed on
2010/03/18
1:31 UTC
Read the original article
Hit count: 455
Hello everybody. I am trying to use JavaScript to start a marquee when a user puts their name into a textbox and then clicks a button. I've got an idea as to how to do it, but my script never fully works. Any help is appreciated!
Here's what I have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function StartMarquee() {
var text = document.getElementById(namebox);
if (text != null) {
document.write("<marquee behavior='scroll' direction='right'>Hello " + text + "!</marquee>");
}
else {
alert("Enter your name first!!!");
}
}
</script>
</head>
<body>
<table style="margin:0px auto 0px auto;">
<tr><td>Enter your name!</td>
<td><input type="text" id="namebox"/></td>
<td><input type="button" value="Enter" onclick="StartMarquee()"/></td></tr>
</table>
</body>
</html>
© Stack Overflow or respective owner