jquery - 当在共享点中选择下拉列表中的选项时,需要 jquery 代码来禁用单选按钮

标签 jquery sharepoint

我正在使用 moss 2007。我创建了一个下拉列,其中有 3 个选项。如果选择了选项 1 和选项 2,则应禁用单选按钮列;如果选择了选项 3,则应启用单选按钮列。我提供了页面源代码,因为我是 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>

问候 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 »

关于jquery - 当在共享点中选择下拉列表中的选项时,需要 jquery 代码来禁用单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6442854/

相关文章:

jquery - 移动全屏背景图片

java - 使用 JQuery 解析 JSON 有困难

共享点权限。需要多个组

regex - 需要识别文件名中的特殊字符

javascript - 如何使用 rest(使用 CAML)在共享点列表中的超链接列上应用过滤器?

jquery - Chrome 无法识别 POST 请求

java - 如何使用 Struts2 jQuery 从 external.js 获取 session 值

javascript - 如何根据屏幕尺寸更改 Angular JS 中的弹出框位置?

azure - Azure SSIS 中的 C# 脚本源 Microsoft.Sharepoint.Client 程序集

sharepoint - 安装 Windows SharePoint Services 3.0 Service Pack 1 后,声明性工作流不会自动启动