How to disable or enable drop down list in JavaScript?
Just create a dropdown list in html form and have an id (mySelect) for that.
Do control of the drop down list in javascript function using the id.
" document.getElementById("mySelect").disabled=true; " it means disable the dropdown list and
" document.getElementById("mySelect").disabled=false; " means enable.
File : DisableorEnable_JS.html
<html>
<head>
<script type="text/javascript">
function disable()
{
document.getElementById("mySelect").disabled=true;
}
function enable()
{
document.getElementById("mySelect").disabled=false;
}
</script>
</head>
<body>
<form>
<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select><br /><br />
<input type="button" onclick="disable()" value="Disable list">
<input type="button" onclick="enable()" value="Enable list">
</form></body>
</html>
=======================
Publicize yourself ... Free!
http://saalram.com
=======================
Jan 24, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Saalram.com