Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2010 03:08
Show Gist options
  • Save anonymous/358465 to your computer and use it in GitHub Desktop.
Save anonymous/358465 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type = "text/javascript">
<!--
function colorChoice(colorButton) {
var color;
var dom = document.getElementById("color");
for (var i = 0; i < dom.colorButton.length; i++) {
if (dom.colorButton[i].checked==true) {
color = dom.colorButton[i].value;
break;
}
}
switch (colorChoice) {
case "1" :
alert('Your favorite color is Red!');
break;
case "2" :
alert('Your favorite color is Blue!');
break;
case "3" :
alert('Your favorite color is Green!');
break;
case "4" :
alert('Your favorite color is Yellow!');
break;
case "5" :
alert('Your favorite color is Orange!');
break;
}
}
//->
</script>
</head>
<body>
<form id="color" action="">
<table>
<td>
<th>What is your favorite color?</th>
</td>
<tr>
<td><input type="radio" name="colorButton" onClick="colorChoice(1);">Red<td></tr>
<td><input type="radio" name="colorButton" onClick="colorChoice(2);">Blue<td></tr>
<td><input type="radio" name="colorButton" onClick="colorChoice(3);">Green<td></tr>
<td><input type="radio" name="colorButton" onClick="colorChoice(4);">Yellow<td></tr>
<td><input type="radio" name="colorButton" onClick="colorChoice(5);">Orange</tr>
</tr>
</table>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment