|
|
|
<head>
<script language="javascript">
function checkAnswers(){
/*declare local variables*/
var joinProgram
var freeHat
var goodWebSite
var message
/*Set up checkbox references*/
joinProgram = document.myForm.joinProgram
freeHat = document.myForm.freeHat
goodWebSite = document.myForm.goodWebSite
/*Is joinProgram checked and goodWebSite not checked checked?*/
if(joinProgram.checked && !goodWebSite.checked){
//Set message to a string
message = "Why do you want to join the program when you hate this web site?"
}else{ //Otherwise
/*Is joinProgram checked and freeHat not checked?*/
if(joinProgram.checked && !freeHat.checked){
/*Set message to a string*/
message = "If your joining the program you can get a FREE red hat!"
}else{//Otherwise
/*Is goodWebSite checked and freeHat checked but joinProgram isn't?*/
if(goodWebSite.checked && freeHat.checked && !joinProgram.checked){
/*Set message to a string*/
message = "I Love this web site just like you and maybe the hat will look good on you\n"
+ "But you can't have the hat if you do not join the program"
}else{//Otherwise
/*Is goodWebSite and freeHat checked and joinProgram*/
if(goodWebSite.checked && freeHat.checked && joinProgram.checked){
/* Set message to a string*/
message = "You are my type of guy!\n Thank you for being interested in the our program\n"
+ " that will keep you up all night while you ware the free hat we are going to give to you.\n"
+ "You get all this and more because you Love this web site and want everything we have to offer!"
}else{//Otherwise
/*Is joinProgram checked and freeHat not checked?*/
if(freeHat.checked && !goodWebSite.checked && !joinProgram.checked){
/* Set message to a string*/
message = "No Hat for you because you do not love the web site and do not wanna join the program"
}else{//Otherwise
/* Set message to a string*/
message = "Love is a wonderful thing but the hat and the program are much more wonderful!"
}
}
}
}
}
alert(message)//alert the message
}
</script>
</head>
<!--
<body><!-- Open the body tag -->
<form name="myForm"><!-- Open the form element and give myForm as it's name -->
<!--Define three checkboxes with a label
and give them a name corresponding to their label-->
<input type="checkbox" name="joinProgram">I want to join the program
<input type="checkbox" name="freeHat">I want free red hat
<input type="checkbox" name="loveWebSite">I Love this web site
<!--Define The button
and make it's onClick event call makeWindow-->
<input type="button" value="Send" onclick="checkAnswers()">
</form><!-- Close the form -->
</body><!-- Close the body element -->