Question: Simple Script help!? Need help getting the following simple script working.  Basically the script takes information from the form and displays it back to the user but I am getting error messages.\n\nThanks!\n\n<?xml version="1.0"?>\n<!DOCTYPE html PUBLIC\n"-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml/11/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">\n\n<head>\n\n<title>Assignment 5</title>\n\n<script type="text/javascript">\ndisplay(f) {\nalert("You started at GSU in " + f.box1)\nvar age\nage = parseFloat(f.box2)\nif (f.box2 >= 21 {\nalert("You are 21 or over.") \n}\nelse {\nalert("You are under 21.")\n}\nif (document.interForm.class[0].checked) {\nalert("You are a Freshman") }\nelse if (document.interForm.class[1].checked) {\nalert("You are a Sophmore") }\nelse if (document.interForm.class[2].checked) {\nalert("You are a Junior") }\nelse if (document.interForm.class[3].checked) {\nalert("You are a Senior!") }\n\n}\n</script>\n\n<style type="text/css">\nh2 {color: white; text-align: center}\nbody {background-color: #999999}\n</style>\n\n</head>\n\n<body>\n<h2>Assignment 5</h2>\n\n<form id="interForm" name="interForm">\nHow many years have you been at GSU?\n<input type="text" name="box1" id="box1" />\n<p>\nHow old are you?\n<input type="text" name="box2" id="box2" />\n</p>\n\n<p>\nPlease click the button that indicates your status at GSU.\n<input type="radio" name="class" id="class" />Freshman<br />\n<input type="radio" name="class" id="class" />Sophmore<br />\n<input type="radio" name="class" id="class" />Junior<br />\n<input type="radio" name="class" id="class" />Senior<br />\n</p>\n\n<p>\nPlease choose your favorite sport.\n<select name="favSport" id="favSport">\n<option>Football</option>\n<option>Baseball</option>\n<option>Soccer</option>\n<option>Basketball</option>\n<option>Swimming</option>\n<option>Other</option>\n</select>\n</p>\n\n<input type="button" onclick="display()" value="Submit" />\n\n</form>\n\n</body>\n\n</html>

Answer: 1. the word 'function' is missing prior to the function name in the javascript code.\n2. missing closing ) in -> if (f.box2 >= 21 {\n4. what is 'f' supposed to represent? No variable is being passed.
This question from the Yahoo Q&A forum is categorized in the topic: Society & Culture