<script type="text/javascript" language="JavaScript">
<!--
function showMyChoices2() {
  var strChoices = "";
  var objCBarray = document.getElementById('myform')['food[]'];
 
  
 
  
  for (i = 0; i < objCBarray.length; i++) {
    if (objCBarray[i].checked) {
      strChoices += "* " + objCBarray[i].value + "\n";
    }
  }
  if (strChoices.length > 0) {
    var strMessage = "Your favorite food(s)\n" + strChoices;
    alert(strMessage);
  } else {
    alert("Please choose your favorite foods.");
  }
}
// -->
</script>
<!--<form id="myform" action="#">-->
<div id ="myform">
<p>My favorite food is?</p>
<input type="checkbox" name="food[]" value="Burgers" /> Burgers<br />
<input type="checkbox" name="food[]" value="Pizza" /> Pizza<br />
<input type="checkbox" name="food[]" value="Spaghetti" /> Spaghetti<br />
<input type="checkbox" name="food[]" value="Tamales" /> Tamales<br />
<input type="button" value="Show My Choices" onclick="showMyChoices2();" />
</div>
<!--</form>-->