From WikiEducator
Jump to: navigation, search


VmvIcon Objectives.png

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

  • Understand how a radio button is created

Radio button (js2_04)

<script type="text/javascript">
function fnCheck() {
if (document.frmChoose.radVal[0].checked) {
  alert("You chose the Add operation");}
if (document.myForm.radVal[1].checked) {
  alert("You chose the Subtract operation");}
<form name="frmChoose">
  <p>Select an operation:</p>
  <p><input type="radio" name="radVal" value="Add" />Add</p>
  <p><input type="radio" name="radVal" value="Subtract" />Subtract</p>
  <input type="button" value="Press Me" onClick="fnCheck()" />

Example :Click here to run js2_04.

VmvIcon References.png References

virtualMV  |  Superquick wiki guide  |  Please give me some feedback

VirtualMV/JavaScript/Forms/RadioButton. (2024). In WikiEducator/VirtualMV wiki. Retrieved February 25, 2024, from http:    (zotero)