Need jquery code to disable radio buttons when a option in dropdown is selected in sharepoint
I am working with moss 2007. I created a drop down column in which has 3 options. If option1 and option 2 are selected the radio button columns should be disabled and if option 3 selected the Radio button columns should be enabled. I provided the page source code, could someone help me out with this with some coding since i am newbie to jquery.
<TR>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Type of Notification</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Type of Notification"
FieldInternalName="Type_x0020_of_x0020_Notification"
FieldType="SPFieldChoice"
-->
<span dir="none"><select name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$DropDownChoice" id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_DropDownChoice" title="Type of Notification" class="ms-RadioText">
<option selected="selected" value="Select One">Select One</开发者_开发百科option>
<option value="Option1">Option1</option>
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
</select><br></span></TD></TR>
<TR>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Does this position have direct reports</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Does this position have direct reports"
FieldInternalName="Does_x0020_this_x0020_position_x0"
FieldType="SPFieldChoice"
-->
<span dir="none"><table cellpadding="0" cellspacing="1">
<tr>
<td><span class="ms-RadioText" title="Yes"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl09$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl00">Yes</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="No"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl09$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl09_ctl00_ctl00_ctl04_ctl00_ctl01">No</label></span></td>
</tr>
</table></span></TD></TR>
<TR>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Spectris Approver</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Spectris Approver"
FieldInternalName="Spectris_x0020_Approver"
FieldType="SPFieldChoice"
-->
<span dir="none"><table cellpadding="0" cellspacing="1">
<tr>
<td><span class="ms-RadioText" title="Yes"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl19_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl19$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl19_ctl00_ctl00_ctl04_ctl00_ctl00">Yes</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="No"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl19_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl19$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl19_ctl00_ctl00_ctl04_ctl00_ctl01">No</label></span></td>
</tr>
</table></span></TD>
</TR>
Regards SP.D
$(document).ready(function(){
$('.ms-RadioText').change(function(){
var opt = $(this).val();
if(opt == 'Option1' || opt == 'Option2'){
$('input:radio').attr('disabled', 'disabled');
} else{
$('input:radio').removeAttr('disabled');
}
});
});
Check it here »
精彩评论