2011-07-15 18 views
0

現在、Jqueryを初めて使用しています.Sharepointリストを使用しています。別のラジオボタン列でオプションが選択されているラジオボタン列を無効にする状況があります。 ラジオボタン列1とラジオボタン列2にはそれぞれ2つのオプションがあります。ラジオボタンcolumn1でオプション2を選択した場合は、ラジオボタンcolumn2全体を無効にする必要があります。以下は、私は以下jqueryを使用して別のラジオボタンのラジオボタン列を無効にする

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> 
    </script> 
    <script language="JavaScript"> 
$(document).ready(function() 
{ 
$('input[name=Who will be developing the propose site?]').change(function(){ 
     if($(this).val() == 'Site Adminstrator') 
     { 
      $('input[name=Has site administrator attest to development operations of Rules of Road]').prop('disabled',true); 
     } 
     else 
     { 
      $('input[name=Has site administrator attest to development operations of Rules of Road]').prop('disabled',false); 
     } 
    }); 
    }); 
    </script> 

に取り組んでいたコードは、ページ(SharePointリスト)

<TR><TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> 
      <nobr>Who will be developing the propose site?</nobr> 
     </H3></TD> 
      <TD valign="top" class="ms-formbody" width="400px"> 
      <!-- FieldName="Who will be developing the propose site?" 
       FieldInternalName="Who_x0020_will_x0020_be_x0020_de" 
       FieldType="SPFieldChoice" 
       --> 
       <span dir="none"><table cellpadding="0" cellspacing="1"> 
     <tr> 
      <td><span class="ms-RadioText" title="CSMS"><input id="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" checked="checked" /><label for="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00">CSMS</label></span></td> 
     </tr><tr> 
      <td><span class="ms-RadioText" title="Site Administrator"><input id="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" /><label for="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl01">Site Administrator</label></span></td> 
     </tr> 
    </table></span></TD></TR> 

      <TR><TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> 
      <nobr>Has site administrator attest to development operations of Rules of Road</nobr> 
     </H3></TD> 
      <TD valign="top" class="ms-formbody" width="400px"> 
      <!-- FieldName="Has site administrator attest to development operations of Rules of Road" 
       FieldInternalName="Has_x0020_site_x0020_administrat" 
       FieldType="SPFieldChoice" 
       --> 
       <span dir="none"><table cellpadding="0" cellspacing="1"> 
     <tr> 
      <td><span class="ms-RadioText" title="Yes"><input id="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl08$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" checked="checked" /><label for="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00">Yes</label></span></td> 
     </tr><tr> 
      <td><span class="ms-RadioText" title="No"><input id="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl08$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" /><label for="ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl01">No</label></span></td> 
     </tr> 
    </table></span></TD></TR> 

のためのSharePointのソースコードは、コード内の任意のヘルプまたは変更されている

種類よろしく非常に便利です BK

+0

Sharepointを操作するために作成されたjavascript/jqueryライブラリのいくつかを調べることができます。 Sharepointページの要素にアクセスすることは大きな苦痛です。 –

答えて

0

以下のコードは私にとって役に立ちました。すべてのあなたの入力をありがとう。あなたが提供した入力のためのコードを構築することができました。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> 
    </script> 
    <script language="JavaScript"> 
    $(document).ready(function() 
    { 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00').attr('disabled', 'disabled'); 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl01').attr('disabled', 'disabled'); 
    OnTypeNotificationChange(); 
    function OnTypeNotificationChange() 
    {    
    $('input[name=ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons]').click(function(){ 

    if($(this).val() == "ctl00") 
     { 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00').attr('disabled', 'disabled'); 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl01').attr('disabled', 'disabled'); 
     } 
     else 
     { 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00').removeAttr('disabled'); 
    $('#ctl00_m_g_7d3ef79b_83fe_4a1f_a469_42a8746f064e_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl01').removeAttr('disabled'); 
     } 
    }); 
     } 
    });</script> 
0

あなたのコードが正しく表示されている場合は、jqueryで使用している名前が、その共有ポイントの自動生成された名前と一致しません入力。

ctl00$m$g_7d3ef79b_83fe_4a1f_a469_42a8746f064e$ctl00$ctl04$ctl07$ctl00$ctl00$ctl04$ctl00$RadioButtons 

Who will be developing the propose site? 

それが動作するはずのようなそうでないコードが見えます。ここで

は動作するはず何か:

HTML:

<TR><TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> 
     <nobr>Who will be developing the propose site?</nobr> 
    </H3></TD> 
     <TD valign="top" class="ms-formbody" width="400px"> 
     <!-- FieldName="Who will be developing the propose site?" 
      FieldInternalName="Who_x0020_will_x0020_be_x0020_de" 
      FieldType="SPFieldChoice" 
      --> 
      <span dir="none"><table cellpadding="0" cellspacing="1"> 
    <tr> 
     <td><span class="ms-RadioText" title="CSMS"><input id="g1button1" type="radio" name="group1" value="CSMS" checked="checked" /><label for="g1button1">CSMS</label></span></td> 
    </tr><tr> 
     <td><span class="ms-RadioText" title="Site Administrator"><input id="g1button2" type="radio" name="group1" value="Site Adminstrator" /><label for="g1button1">Site Administrator</label></span></td> 
    </tr> 
</table></span></TD></TR> 

     <TR><TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> 
     <nobr>Has site administrator attest to development operations of Rules of Road</nobr> 
    </H3></TD> 
     <TD valign="top" class="ms-formbody" width="400px"> 
     <!-- FieldName="Has site administrator attest to development operations of Rules of Road" 
      FieldInternalName="Has_x0020_site_x0020_administrat" 
      FieldType="SPFieldChoice" 
      --> 
      <span dir="none"><table cellpadding="0" cellspacing="1"> 
    <tr> 
     <td><span class="ms-RadioText" title="Yes"><input id="g2button3" type="radio" name="group2" value="ctl00" checked="checked" /><label for="g2button3">Yes</label></span></td> 
    </tr><tr> 
     <td><span class="ms-RadioText" title="No"><input id="g2button2" type="radio" name="group2" value="ctl01" /><label for="g2button2">No</label></span></td> 
    </tr> 
</table></span></TD></TR> 

のjQuery:ここ

$('input[name=group1]').change(function() 
{ 
    if($(this).val() == 'Site Adminstrator') 
    { 
     $('input[name=group2]').prop('disabled',true); 
    } 
    else 
    { 
     $('input[name=group2]').prop('disabled',false); 
    } 
}); 

テストを: http://jsfiddle.net/jL5A5/1/

+0

これは、共有ページの自動生成ソースコードです。私は自分の手にしているものを扱っている。 – Bk8579

+0

入力グループの名前を変更できない場合は、次のようなクラスまたはhtml5データ属性を使用してみてください。

0

ここでフィドル:http://jsfiddle.net/gm5N8/

あなたのコードは軽く変更されましたが、私はあなたが狂った名前/ ids /値を持っていると言わなければなりません。彼らはひどいです。少なくともあなたは読み込み不可能な名前/ IDを持っていて、値は非常に奇妙です(ctl01またはctl00など)。ねえ、彼らと一緒に何かを作ってください。

+0

シェアポイントページ。私は自分の手にしているものを扱っている。 – Bk8579

+0

私は知っている、JSにClientIDsを渡してみて、 –

関連する問題