/    Sign up×
Community /Pin to ProfileBookmark

Need help on my javaScript code

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=”Display Text Field contents” onClick=”alert(text_field.value);”>
</form>

</body>

</html>
? What am I doing wrong?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@DrDaMourApr 29.2003 — onLoad="greet_visitor();scrollMarquee();"
Copy linkTweet thisAlerts:
@agunterauthorMay 02.2003 — Thanks for replying. I did just that and the visitor prompt worked but it didn't print out the name of the visitor above the scrolling marquee.

I did: document.write("Welcome, " +visitor_name+ "!</b>") ;

Please help.
Copy linkTweet thisAlerts:
@agunterauthorMay 06.2003 — Never mind... I figured it out. Thank you
×

Success!

Help @agunter spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...