Last updated on October 4th, 2022 at 01:32 pm

This tutorial will explain how to disable dropdown list inside a form using javascript. If you have lets say a dropdown list of two values then you can disable that using javascript when you mark a checkbox.

Disable Dropdown List Using Javascript
Disable Dropdown List Using Javascript


Here as an example I have a form named “frm” and the selection named “sel“. I can use Javascript to disable it by calling document.frm.sel.disabled. Try to save the code below to an HTML page and run it to check how it works.

<form name="frm">
<select name="sel">
<option value="1">one</option>
<option value="2">two</option>
</select>
<input type="checkbox" onclick="disable(this.checked)" /> Disable
</form>
<script language="JavaScript">
function disable(disableIt)
{
    document.frm.sel.disabled = disableIt;
}
</script>

(NOTE:- Page updated on 15th Jun 2016. Originally posted on 16th September 2010 – Page reviewed again on Oct 4 2022)

Leave a Reply

Your email address will not be published. Required fields are marked *