IT/jquery

table 안의 라디오버튼 하나씩 체크

밤톨순이 2016. 12. 15. 11:26

// 그리드 라디오버튼 하나만 선택하게 하는 함수
   function RdoBtnClient(obj) {
                // 전체 체크 취소
       $("#divContentTable").find("input:radio").prop("checked", false);

       // 선택된 라디오버튼 체크
                $("#" + obj.id).prop("checked", true);
   }

<table id="divContentTable" class="TblNoBorder" style="TABLE-LAYOUT: fixed; width:780px;">
                        <colgroup>
             <col width="30px" />
             <col width="70px" />
             <col width="200px" />
             <col width="120px" />
             <col width="120px" />
             <col width="80px" />
             <col width="120px" />
            </colgroup>
                        <asp:repeater id="RptList" Runat="server">
             <ItemTemplate>
              <tr style="cursor:hand;" no_onmouseover="this.style.backgroundColor='white'" no_onmouseout="this.style.backgroundColor='white'"
               bgcolor="White">
               <td class="ListCode" no_onclick=""><input type="radio" Runat="server" ID="RdoBtn" name="RdoBtn" VALUE="RdoBtn"></td>
               <td class="ListCode" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_SiteCode" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"site_code")%>' /></td>
               <td class="ListText" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_SiteName" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>' /></td>
               <td class="ListCode" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_Sojang" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"Sojang")%>' /></td>
               <td class="ListCode" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_AnjunManager" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"AnjunManager")%>' /></td>
               <td class="ListCode" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_JudgeDate" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>' /></td>
               <td class="ListCode" style="cursor:hand;" no_onclick="ViewRevision('<%#DataBinder.Eval(Container.DataItem,"site_code")%>','<%#DataBinder.Eval(Container.DataItem,"lot_nam")%>','<%#DataBinder.Eval(Container.DataItem,"Judge_Date","{0:d}")%>','<%# Container.ItemIndex %>', this);">
                <asp:Label ID="Lbl_Writer" Runat="server" text='<%#DataBinder.Eval(Container.DataItem,"Writer")%>' /></td>
               <input type="hidden" runat="server" id="hid_Newform" value=<%# DataBinder.Eval(Container.DataItem,"New_form")%> NAME="hid_Newform">
               <input type="hidden" runat="server" id="hid_type" value=<%# DataBinder.Eval(Container.DataItem,"Gongsa_Type")%> NAME="hid_type">
              </tr>
             </ItemTemplate>
            </asp:repeater>
                    </table>

for(int i=0; i < RptList.Items.Count; i++)
                string JScript = "RdoBtnClient(this);";
    ((HtmlInputRadioButton)RptList.Items[i].FindControl("RdoBtn")).Attributes.Add("no_onclick", JScript);
   }