View Single Post
Old 10-26-2012, 10:15 PM   PM User | #4
jolimk
New to the CF scene

 
Join Date: Sep 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
jolimk is an unknown quantity at this point
Quote:
Originally Posted by rdspoons View Post
This may help. You can compare the code and the comments to your original code.
Code:
<HTML>
<body>
<script type="text/javascript">
//You may want to add your own default word for the prompt to 
//avoid the prompt's 'undefined' default.
var name=prompt("Hi. Whats your name?","friend")

var mood=prompt("Hi " + name + ". How are you?") //'undefined' is the default answer
var fine="fine"
var bad="bad"

//remember to put your conditional comparisons inside of parentheses.
if(mood==fine)
	alert("Im glad you are fine, " + name)
//you can use an if..else if.. else struture to allow a default 
//answer if neither 'fine' nor 'bad' are given as the response.
//dont' forget mood=bad is an asignment, not a comparison.
else if(mood==bad)
	alert("Ooo. Thats bad, Im sorry. I hope you get better, " + name)
//and maybe add a default greeting in case 'fine' or 'bad' are not entered
else
	alert("So..., it looks like you're in a " + mood +" mood, " + name)

//And don't forget to close the script tag
</script>

</body>
</SCRIPT>
</HTML>
Thanks actually worked thank you very mcuh youre such a pro
jolimk is offline   Reply With Quote