I need help on an assignment...I'm stuck. I'm having trouble with my javaScript code so I created two different file but I need to combine code to one. My question is how can I edit my jsExample file to display the visitor's name as part of a welcome message directly above the scrolling marquee; instead of the alert I have on my greetVisitor code. How can I have it prompt the visitor to enter name before the page loads? I'm having problem getting it to work, my marquees stops working. Please help.
Here's my code:
1.)jsExample
<html>
<head>
<title>JavaScript Examples 1</title>
<script LANGUAGE="JavaScript">
<!--
var message = " The good news: Computers allow us to work 100% faster. The bad news: They generate 300% more work. ";
var marqueeMessage = new String();
function scrollMarquee() {
marqueeMessage = document.marqueeForm.marqueeText.value;
document.marqueeForm.marqueeText.value = marqueeMessage.substring(1) + marqueeMessage.substring(0, 1);
setTimeout('scrollMarquee()', 200);
}
//-->
</script>
</head>
<body onLoad="scrollMarquee();">
<h3>AGunter</h3>
<h1 align="center">JavaScript Examples 1</h1>
<form NAME="marqueeForm">
<font FACE="Arial" SIZE="3"><b>
<input NAME="marqueeText" SIZE="30">
<script LANGUAGE="JavaScript">
<!--
document.marqueeForm.marqueeText.value = message;
//-->
</script>
</b></font>
</body>
</html>
2.) GreetVisitor
<html>
<head>
<title>JavaSript Events</title>
<script language="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var visitor_name= "";
function greet_visitor(){
visitor_name=prompt("Please enter your name","Enter your name here") ;
alert("Welcome, "+visitor_name+ "!") ;
}
function farewell_visitor() {
alert("Thanks, "+visitor_name+", for visiting this Web page!") ;
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body onLoad="greet_visitor();" onUnload="farewell_visitor();">
<form>
<input type="text" Name="text_field" Size="25" onChange="alert('The value of the text_field has changed.');"><br>
<input type="button" Value=http://www.webdeveloper.com/forum/archive/index.php/"Display Text Field contents" onClick="alert(text_field.value);">
</form>
</body>
</html>
What am I doing wrong?
Here's my code:
1.)jsExample
<html>
<head>
<title>JavaScript Examples 1</title>
<script LANGUAGE="JavaScript">
<!--
var message = " The good news: Computers allow us to work 100% faster. The bad news: They generate 300% more work. ";
var marqueeMessage = new String();
function scrollMarquee() {
marqueeMessage = document.marqueeForm.marqueeText.value;
document.marqueeForm.marqueeText.value = marqueeMessage.substring(1) + marqueeMessage.substring(0, 1);
setTimeout('scrollMarquee()', 200);
}
//-->
</script>
</head>
<body onLoad="scrollMarquee();">
<h3>AGunter</h3>
<h1 align="center">JavaScript Examples 1</h1>
<form NAME="marqueeForm">
<font FACE="Arial" SIZE="3"><b>
<input NAME="marqueeText" SIZE="30">
<script LANGUAGE="JavaScript">
<!--
document.marqueeForm.marqueeText.value = message;
//-->
</script>
</b></font>
</body>
</html>
2.) GreetVisitor
<html>
<head>
<title>JavaSript Events</title>
<script language="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var visitor_name= "";
function greet_visitor(){
visitor_name=prompt("Please enter your name","Enter your name here") ;
alert("Welcome, "+visitor_name+ "!") ;
}
function farewell_visitor() {
alert("Thanks, "+visitor_name+", for visiting this Web page!") ;
}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body onLoad="greet_visitor();" onUnload="farewell_visitor();">
<form>
<input type="text" Name="text_field" Size="25" onChange="alert('The value of the text_field has changed.');"><br>
<input type="button" Value=http://www.webdeveloper.com/forum/archive/index.php/"Display Text Field contents" onClick="alert(text_field.value);">
</form>
</body>
</html>
What am I doing wrong?