Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 15th, 2005, 2:13 PM   #1
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 290
Rep Power: 4 Ghost is on a distinguished road
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.
Ghost is offline   Reply With Quote
Old Nov 15th, 2005, 2:22 PM   #2
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 3 Agent 47 is on a distinguished road
<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>
--47.
__________________
"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"
Agent 47 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC