Need help on javaScript assignment

wxdqz

New Member
I have this assignment I can't get to work. Here's the assignment:

Create a Web page with an if...else statment that asks user whether they want to see a personalized greeting. If they select yes, display a prompt dialog box asking for their name, then display the name in an alert dialog box. If they selct no, display a generic greeting in an alert dialog box.

here's my code:
<html>

<head>
<title>Personal Greeting</title>
<script language="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

function seeGreeting(answer) {
if (answer == "yes")
var greeting = prompt("What is your name?");
alert("Hello, " +greeting+ " Hope you're enjoying the site") ;
}
else
{
alert("Welcome")
}



// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>

<body>
<h1>Personal Greeting</h1>
<form>
<p><b>Would you like to see a Personalize Greeting?</b>
<input type=radio Name=greeting Value=http://www.webdeveloper.com/forum/archive/index.php/"yes" onClick="seeGreeting(this.value)">
<b>Yes</b>
<br>
<input type=radio Name=greeting Value="no" onClick="seeGreeting(this.value)">
<b>No</b>
</p>
</form>
</body>

</html>


when I click no, it shows the alert for yes... what am I doing wrong? Please Help.
agunter
 
Back
Top