Posted by : food Friday, 31 May 2013

Enable and Disable Two Select box Using Radio Button


Enable and disable drop down list in javascript



Simply Write Below code in Text editor (ANY Notepad , Dreamweaver , Notepad ++ ).

Code is as Below:

<html>
<body onLoad="cLoad()">
<script language="javascript">
function c1()
{
f1.s1.disabled=false;
f1.s2.disabled=true;
}
function c2()
{
f1.s1.disabled=true;
f1.s2.disabled=false;
}
function cLoad()
{
f1.g1[0].checked="unchecked";
f1.s2.disabled=true;
}
</script>
<fieldset style="width:180px;">

<form name="f1">
<legend>
<input type="radio" name="g1" onClick="c1()">Food
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="g1" onClick="c2()">Drinks
<br><br>
<select name="s1">
<option>Vadapav</option>
<option>Dabeli</option>
<option>Bhajipav</option>
<option>Gathiya</option>
<option>Khaman</option>
</select>
<select name="s2">
<option>Sprite</option>
<option>Mazza</option>
<option>Slice</option>
<option>Thums up</option>
<option>Fanta</option>
</select>
</legend>
</form>
</fieldset>
</body>
</html>


Output is Like this :

Food        Drinks

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Web Designing & SEO Blog - Web Designing and SEO Blog