Disable or enable listbox inside a form

We can disable or enable a listbox by using its disabled property. Here is an example.
Here we have given the id of l1 to our dropdown listbox. We can enable the listbox ( available for selecting element ) by changing the property to false.
To learn this we will use one radio button and onclick of radio button we will execute one function radio_check() to change the property

Here is the demo of disabling listbox

Here is the code.
<title>Demo of JavaScript listbox disable or enable in a form</title>
<script type="text/javascript">
function radio_check()

function data_check()
var str=document.getElementById("l1").value;
if(str.length <=0){
alert("Please select one option ");
document.forms['drop_list'].submit();// working
<form name="drop_list" action="listbox-validation-demock.php" method="post" id='f1'>
Do you want to learn Web programming languages ? 
<input type=radio name=choice value='yes' onClick="radio_check()";>Yes
 <input type=radio name=choice value='no' onClick="radio_check()";>No 

<select name="Category" id="l1">
<option value=''>Select One</option>
<option value="PHP">PHP</option>
<option value="ASP">ASP</option>
<option value="JavaScript">JavaScript</option>
<option value="HTML with design">HTML</option>
<option value="Perl">Perl</option><option value="MySQL">MySQL</option></select>
<input onclick="data_check()"; value="Submit Form" type="button"> 


Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Aejaz Rathore


    Exclnt site, concepts are presented in a professional way Thankz

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer