下拉框option禁選

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
.disabled {
  color: #999;
}
</style>
<script type="text/javascript">
function preventSelectDisabled(oSelect) {
    var isOptionDisabled = oSelect.options[oSelect.selectedIndex].disabled;
    if(isOptionDisabled) {
        oSelect.selectedIndex = oSelect.defaultSelectedIndex;
        return false;
    }
    else oSelect.defaultSelectedIndex = oSelect.selectedIndex;
    return true;
}

</script>

</head>

<body>
<select name="Type" id="ReportName" class="textinput"
        οnchange='return preventSelectDisabled(this)'>
        <option value="reportAsset">
          Positions Summary
        </option>

        <option value="reportOptions">
          Account Transactions
        </option>
        <option value="reportOptions">
          Performance Summary
        </option>

        <option disabled='disabled' class='disabled'>

          Asset Allocations
        </option>
       
        <option disabled='disabled' class='disabled'>
          Options Tracking
        </option>

        <option disabled='disabled' class='disabled'>
          Historical Variance
        </option>

        <option disabled='disabled' class='disabled'>
          Portfolio Statistics
        </option>
      </select>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章