![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4
![]() |
Disable Drop Downlist Using Radio Buttons
Hey I need some help...a lot of help with JavaScript.
I need it so when Yes is selected from a radio button list, the drop down list then becomes enabled and when no is selected it becomes disabled. Here are the elements I have. I need the javascript code.... Radio Buttons -------------------------------- <table id="_ctl0_RadioButtonListSalesAgent" onClick="enableDisable()" border="0" style="height:40px;width:240px;"> <tr> <td><input id="_ctl0_RadioButtonListSalesAgent_0" type="radio" name="_ctl0:RadioButtonListSalesAgent" value="1" /><label for="_ctl0_RadioButtonListSalesAgent_0">Yes, and my agents name is:</label></td> </tr><tr> <td><input id="_ctl0_RadioButtonListSalesAgent_1" type="radio" name="_ctl0:RadioButtonListSalesAgent" value="0" checked="checked" /><label for="_ctl0_RadioButtonListSalesAgent_1">No, please assign an agent.</label></td> </tr> </table> Dropdown List ------------------ <select name="_ctl0:DropDownListSalesAgent" id="_ctl0_DropDownListSalesAgent" disabled="disabled" class="PhoneEdit" style="width:200px;"> <option value="User1">User1</option> <option value="User2">User2</option> </select> Thank you javascript people. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
<script type="text/JavaScript">
//<![CDATA[
function toggle(v,s)
{
document.getElementById(s).disabled=v;
}
//]]>
</script>
</head>
<body>
<form name="f1">
<div>
<label for="_ctl0_RadioButtonListSalesAgent_0">
<input id="_ctl0_RadioButtonListSalesAgent_0" type="radio" name="_ctl0:RadioButtonListSalesAgent" value="1" onclick="toggle(false,'_ctl0_DropDownListSalesAgent');" />
Yes, and my agents name is:
</label>
<label for="_ctl0_RadioButtonListSalesAgent_1">
<input id="_ctl0_RadioButtonListSalesAgent_1" type="radio" name="_ctl0:RadioButtonListSalesAgent" value="0" checked="checked" onclick="toggle(true,'_ctl0_DropDownListSalesAgent');" />
No, please assign an agent.
</label>
<select name="_ctl0:DropDownListSalesAgent" id="_ctl0_DropDownListSalesAgent" disabled="disabled" class="PhoneEdit" style="width:200px;">
<option value="User1">User1</option>
<option value="User2">User2</option>
</select>
</div>
</form>
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|