2012-12-24 110 views
1

我有一個帶文本框和單選按鈕的中繼器。我想要做的就是在彈出窗口(jqmWindow)的關閉處獲取選定的文本框值。Jquery從中繼器獲取選定文本框的值

<div class="jqmWindow" id="dialog" style="display: none;"> 
    <table width="100%" border="0px" cellpadding="0px" cellspacing="0px"> 
     <tr> 
      <td> 
       <asp:Repeater runat="server" ID="rptDaysInField" EnableViewState="false"> 
        <HeaderTemplate> 
         <table id="tblPopUp" class="clsForm spacing" style="behavior: url(../script/tablehighlight.htc);" 
          hlcolor="#CECECE" slcolor="#CECECE"> 
          <thead> 
           <tr class="header"> 
            <td width="0%"> 
            </td> 
            <td width="40%"> 
             <MultiLang:LocalizedLiteral ID="LocalizedLiteral2" runat='server' Key="CoacheeName"> 
             </MultiLang:LocalizedLiteral> 
            </td> 
            <td width="20%"> 
             <MultiLang:LocalizedLiteral ID="LocalizedLiteral9" runat='server' Key="SessionDate"> 
             </MultiLang:LocalizedLiteral> 
            </td> 
            <td width="10%"> 
             <MultiLang:LocalizedLiteral ID="LocalizedLiteral10" runat='server' Key="# Days"> 
             </MultiLang:LocalizedLiteral> 
            </td> 
            <td width="20%"> 
             <MultiLang:LocalizedLiteral ID="LocalizedLiteral11" runat='server' Key="Days To Transfer"> 
             </MultiLang:LocalizedLiteral> 
            </td> 
            <td width="10%"> 
            </td> 
           </tr> 
          </thead> 
        </HeaderTemplate> 
        <ItemTemplate> 
         <tr> 
          <td width="0%"> 
           <asp:HiddenField ID="hidId" runat="server" Value='<%#(DataBinder.Eval(Container, "DataItem.CoacheeId"))%>' /> 
          </td> 
          </td> 
          <td width="40%"> 
           <%# DataBinder.Eval(Container, "DataItem.CoacheeName")%> 
          </td> 
          <td width="20%"> 
           <%# DataBinder.Eval(Container, "DataItem.SessionDate")%> 
          </td> 
          <td width="10%"> 
           <%# DataBinder.Eval(Container, "DataItem.Days")%> 
          </td> 
          <td width="20%"> 
           <asp:TextBox ID="rptTxtDaysToTransfer" class="clsRptTxtDaysToTransfer" runat="server"></asp:TextBox> 
          </td> 
          <td width="10%"> 
           <asp:RadioButton ID="rdSelectDaysToTransfer" class="clsRdSelectDaysToTransfer" runat="server" /> 
          </td> 
         </tr> 
        </ItemTemplate> 
        <FooterTemplate> 
         </table> 
        </FooterTemplate> 
       </asp:Repeater> 
      </td> 
     </tr> 
    </table> 
    <a href="#" class="jqmClose" id="dialogClose" style="float:right;">Close</a> 
</div> 

我使用下面的jQuery代碼:

$(".jqmClose").click(function() { 
      $(".clsRdSelectDaysToTransfer").each(function() { 
       if ($(this).find("input[type=radio][id*=rdSelectDaysToTransfer]").attr("checked")) { 
        alert($(this).find(".clsRptTxtDaysToTransfer input[type=text][id*=rptTxtDaysToTransfer]").val()); 
       } 
      }); 
     }); 

通過它給我的選擇單選按鈕,但仍然在努力獲得文本框的值。

請幫我拿到文本框的值。

感謝

回答

0

試試這個:

if ($(this).find("input[type=radio][id*=rdSelectDaysToTransfer]").attr("checked")) { 
    var value = $(this).closest('tr').find('input.clsRptTxtDaysToTransfer').val(); 
    alert(value); 
}​ 
+0

愛你彼得.. :) –