Tuesday, 27 September 2011

Remove selected option from a dropdown list/combobox in JavaScript


<html>
<head>
<script type="text/javascript">
      function DeleteSelOption()
      {
            var x = document.getElementById("ddlTech")
            x.remove(x.selectedIndex)
      }
</script>
</head>

<body>
<form>
      <select id="ddlTech">
        <option>Dot Net</option>
        <option>PHP</option>
        <option>Flex</option>
      </select>

      <input type="button" onclick="DeleteSelOption()" value="Remove Selected option">
</form>
</body>

</html>

No comments:

Post a Comment