Passing a Form Object and Form Element to Functions
<HTML> <HEAD> <TITLE>Beatle Picker</TITLE> <SCRIPT LANGUAGE="JavaScript"> function processData(form) { for (var i = 0; i < form.CheckBoxes.length; i++) { if (form.CheckBoxes[i].checked) { break; } } var beatle = form.CheckBoxes[i].value; var song = form.song.value; alert(song + " " + beatle); } function verifySong(entry) { var song = entry.value; alert(song); } </SCRIPT> </HEAD> <BODY> <FORM onSubmit="return false"> Choose your favorite Beatle: <INPUT TYPE="radio" NAME="CheckBoxes" VALUE="J" CHECKED>J <INPUT TYPE="radio" NAME="CheckBoxes" VALUE="P">P <INPUT TYPE="radio" NAME="CheckBoxes" VALUE="G">G <INPUT TYPE="radio" NAME="CheckBoxes" VALUE="R">R<P> Enter the name of your favorite song:<BR> <INPUT TYPE="text" NAME="song" VALUE = "test" onChange="verifySong(this)"><P> <INPUT TYPE="button" NAME="process" VALUE="Process Request..." onClick="processData(this.form)"> </FORM> </BODY> </HTML>