Form – CheckBox

[Total: 0    Average: 0/5]

This shows how to determine which options of a checkbox are selected.

Body Code:

<form name=exf1>
1<input type="checkbox" name="c1" onclick=showpicks() value="1"><BR>
2<input type="checkbox" name="c2" onclick=showpicks() value="2"><BR>
3<input type="checkbox" name="c3" onclick=showpicks() value="3"><BR>
4<input type="checkbox" name="c4" onclick=showpicks() value="4"><BR>
5<input type="checkbox" name="c5" onclick=showpicks() value="5"><BR>
6<input type="checkbox" name="c6" onclick=showpicks() value="6"><BR>
<input type=text onfocus=blur() name=t1 value="?">
</form>
<script type=text/javascript>
function showpicks() {
  _s = "";
  if (document.exf1.c1.checked) _s += "1 ";
  if (document.exf1.c2.checked) _s += "2 ";
  if (document.exf1.c3.checked) _s += "3 ";
  if (document.exf1.c4.checked) _s += "4 ";
  if (document.exf1.c5.checked) _s += "5 ";
  if (document.exf1.c6.checked) _s += "6 ";
  document.exf1.t1.value = _s;
}
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *