下拉列表1“通知类型”选项员工/承包商请假,员工/承包商从休假状态返回,更换主管等等
单选按钮1列名称分区(上面提供的选项将被禁用)
单选按钮2列名称国家/地区(应为下拉列表中选择的每个选项启用)
<script language="JavaScript">
$('.ms-RadioText').change(function(){
var opt = $(this).val();
if(opt == 'Employee/Contractor Leave of Absence' || opt == 'Employee/Contractor Return from Leave of Absence' || opt == 'Change of Supervisor')
{
$('input:radio').attr('disabled', 'disabled');
}
else
{
$('input:radio').removeAttr('disabled');
}
});
</script>
使用上面的代码我可以禁用页面
中的每个单选按钮$('.ms-RadioText').change(function(){
var opt = $(this).val();
if(opt == 'Employee/Contractor Leave of Absence' || opt == 'Employee/Contractor Return from Leave of Absence' || opt == 'Change of Supervisor' || opt == 'Separation from Abbott or GPRD/Clinical')
{
$('input[name='Division']:radio').attr('disabled', 'disabled');
}
else
{
$('input[name='Division']:radio').removeAttr('disabled');
}
});
目前正在使用上述代码,但没有继续前进
高度赞赏的任何见解
源代码
<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$ctl03$ctl00$ctl00$ctl04$ctl00$DropDownChoice" id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_DropDownChoice" title="Type of Notification" class="ms-RadioText">
<option value="Select One">Select One</option>
<option value="New Employee/Contractor">New Employee/Contractor</option>
<option value="Employee/Contractor Position Change">Employee/Contractor Position Change</option>
<option value="Contractor to Employee">Contractor to Employee</option> <option value="Employee/Contractor Leave of Absence">Employee/Contractor Leave of Absence</option>
<option value="Employee/Contractor Return from Leave of Absence">Employee/Contractor Return from Leave of Absence</option>
<option value="Name Change">Name Change</option> <option selected="selected" value="Change of Supervisor">Change of Supervisor</option>
</select><br></span>
</TD>
</TR>
<TR>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Division</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Division"
FieldInternalName="Division"
FieldType="SPFieldChoice"
-->
<span dir="none"><table cellpadding="0" cellspacing="1">
<tr>
<td><span class="ms-RadioText" title="Affiliate"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00">Affiliate</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="GPRD"><input id="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl01">GPRD</label></span></td>
</tr>
</table></span>
Division of the Requestor
</TD>
</TR>
<TR>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Are you Manager</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Are you Manager"
FieldInternalName="Are_x0020_you_x0020_Manager"
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_ctl38_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl38$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" checked="checked" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl38_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_ctl38_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_785c653c_cfa1_4aa5_8060_a84901274cc3$ctl00$ctl04$ctl38$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" /><label for="ctl00_m_g_785c653c_cfa1_4aa5_8060_a84901274cc3_ctl00_ctl04_ctl38_ctl00_ctl00_ctl04_ctl00_ctl01">No</label></span></td>
</tr>
</table></span>
Authorisation to approve
</TD>
</TR>
答案 0 :(得分:1)
对于这一行(以及使用相同jQuery选择器的另一行):
$('input[name='Division']:radio').attr('disabled', 'disabled');
当使用带引号的选择器时,它们需要与用于定义字符串的引号不同。您使用单引号来定义字符串,因此请在属性值“Division”周围使用双引号。
$('input[name="Division"]:radio').attr('disabled', 'disabled');
答案 1 :(得分:1)
将jQuery与.NET控件一起使用时,在尝试选择.NET服务器控件(如文本框,单选按钮等)时使用的一种很好的技巧是在jQuery中使用“属性结束”选择器,即{{ 1}}。由于.Net生成的ID几乎总是以您指定的ID结束,因此您可以使用[attribute$=some_text]
。如果您将其与更具体,更清晰的选择器相结合以提高效率,您可以尝试,在您的情况下:
[id$=Division]
注意我在使用变量来存储jQuery对象时使用了这个约定,这些对象的名字前缀为“$”,以表明它是一个jQuery对象。
答案 2 :(得分:0)
我认为你需要改变
$('input[name='Division']:radio')
类似
$('input[name='+Division+']:radio')
p / s:我假设Division是变量