VirtualMV/JavaScript/Forms/CheckBox

From WikiEducator
Jump to: navigation, search




Overview

VmvIcon Objectives.png

By the end of this page you will be able to:

  • Understand how a check box is created

Check box (js2_05)

<html><body>
<script type="text/javascript">
<!--
function fnCheck() {
  var strX = "";
  objDrink=document.frmChoose.chkDrinks;
  if (objDrink[0].checked) {strX = strX + objDrink[0].value +" ";};
  if (objDrink[1].checked) {strX = strX + objDrink[1].value +" ";};
  if (objDrink[2].checked) {strX = strX + objDrink[2].value + " ";};
  alert("You have selected: " +strX);
}
//-->
</script>
<form name="frmChoose">
<input type="checkbox" name="chkDrinks" value="milk" />Milk<br />
<input type="checkbox" name="chkDrinks" value="cream" />Cream<br />
<input type="checkbox" name="chkDrinks" value="sugar" />Sugar<br />
<input type="button" value="Order" onClick="fnCheck()" />
</form>
</body></html>

Example :Click here to run js2_05.

VmvIcon References.png References

virtualMV  |  Superquick wiki guide  |  Please give me some feedback

VirtualMV/JavaScript/Forms/CheckBox. (2024). In WikiEducator/VirtualMV wiki. Retrieved December 22, 2024, from http:https://wikieducator.org/VirtualMV/JavaScript/Forms/CheckBox    (zotero)