VirtualMV/JavaScript/Forms/Select

From WikiEducator
Jump to: navigation, search




Overview

VmvIcon Objectives.png

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

  • Understand how a combo (select) drop box is created

select (js2_03)

<html></body>
<script type="text/javascript">
<!--
function fnDisplaySelect() {
  objRef=document.frmChoose.cboNumber; // we are creating an object which means we don't need to key as much on the next line
  intSelectvalue=objRef.options[objRef.selectedIndex].value;
  alert("You chose the number " + intSelectvalue);
}
//-->
</script>
<form name="frmChoose">
  <select name="cboNumber">
    <option value="10">Ten</option>
    <option value="20">Twenty</option>
    <option value="30">Thirty</option>
  </select>
  <input type="button" value="Display Selection" 
         onClick="fnDisplaySelect()" />
</form>
</body></html>

Example :Click here to run js2_03.

VmvIcon References.png References

virtualMV  |  Superquick wiki guide  |  Please give me some feedback

VirtualMV/JavaScript/Forms/Select. (2024). In WikiEducator/VirtualMV wiki. Retrieved March 28, 2024, from http:https://wikieducator.org/VirtualMV/JavaScript/Forms/Select    (zotero)