<html>
<head>
<title>Beatle Picker</title>
<script type="text/javascript">
function processData(form) {
for (var i = 0; i < form.Beatles.length; i++) {
if (form.Beatles[i].checked) {
break;
}
}
var chosenBeatle = form.Beatles[i].value;
var chosenSong = form.song.value;
alert(chosenSong + " " + chosenBeatle );
}
function checkSong(songTitle) {
var enteredSong = songTitle.value;
alert(enteredSong);
}
</script>
</head>
<body>
<form name="Abbey Road">
Choose your favorite Beatle:
<input type="radio" name="Beatles" id="Beatles1" value="John Lennon" checked="true" />John
<input type="radio" name="Beatles" id="Beatles2" value="Paul McCartney" />Paul
<input type="radio" name="Beatles" id="Beatles3" value="George Harrison" />George
<input type="radio" name="Beatles" id="Beatles4" value="Ringo Starr" />Ringo
<p>Enter the name of your favorite Beatles song:<br />
<input type="text" name="song" id="song" value="value" onchange="checkSong(this)" /></p>
<p><input type="button" name="process" id="process" value="Process" onclick="processData(this.form)" /></p>
</form>
</body>
</html>
|