2012-01-26 13 views
0

私はテーブルからjQueryを使用してテーブルからtd入力のテキストボックス値を取得する方法は?

<asp:TextBox ID="txtTotalAmount" CssClass="classTotalAmount number" Columns="8" runat="server"></asp:TextBox> 

の値を取得したいです。

のaspxファイルでは:jQueryので

<table id="tblitems" cellpadding="0" cellspacing="0" border="0" class="additemtb"> 
    <tbody> 
     <tr> 
      <th> 
       Item Name 
      </th> 
      <th> 
       Item Code 
      </th> 
      <th> 
       Unit Price 
      </th> 
      <th> 
       Qty 
      </th> 
      <th> 
       UOM 
      </th> 
      <th> 
       Amount 
      </th> 
      <th> 
       Minimal Order Qty 
      </th> 
      <th> 
       FOC 
      </th> 
      <th></th> 
     </tr> 
     <tr> 
      <td style="width:190px;"> 

      </td> 
      <td> 
       <asp:TextBox ID="TxtBox_ItemCode" CssClass="classItemCode readonly" Columns="8" runat="server" ></asp:TextBox> 
      </td> 
      <td style="white-space:nowrap"> 
       <input type="text" id="txtunitprice" name="txtunitprice" class="classUnitPrice number readonly" style="width:50px;" /> 
       <input type="hidden" id="hidunitprice" name="hidunitprice" class="classUnitPrice2" /> 
       <asp:Label ID="lblCurrency" runat="server" CssClass="classCurrency" /> 
       <input type="hidden" id="hidcurrencyid" name="hidcurrencyid" class="classCurrencyID" /> 
      </td> 
      <td> 
       <input type="text" id="txtqty" name="txtqty" class="classQty number decimaltextbox" style="width:50px" onkeyup="calculateAmount(this);" onblur="minamt(this);calculateAmount(this);" /> 
      </td> 
      <td> 
       <asp:TextBox ID="TxtBox_UOM" CssClass="classUOM readonly" Columns="5" runat="server" ></asp:TextBox> 
      </td> 
      <td style="white-space:nowrap"> 
       <asp:TextBox ID="TxtBox_Amount" CssClass="classAmount number readonly" Columns="8" runat="server"></asp:TextBox> 
       <asp:Label ID="Label1" runat="server" CssClass="classCurrency2" /> 
      </td> 
      <td> 
       <input type="text" id="txtminorderqty" name="txtminorderqty" class="minorderqty number readonly" style="width:60px;background:none;border:none;font-weight:bold;color:Red;" /> 
      </td> 
      <td style="width:1px"> 
       <input type="checkbox" id="chkFOC" name="chkFOC" class="classFOC btnborder" onclick="calculateFOC(this);" /> 
       <input type="hidden" name="hidFOC" id="hidFOC" class="classFOC2" value="false" /> 
      </td> 
      <td style="width:90px;"> 
       <a href="javascript:void(0)" class="copy" onclick="copyRow(this);">Copy</a> 
       <a href="javascript:void(0)" class="delete" onclick="removeRow(this);">delete</a> 
       <a href="javascript:void(0)" class="add" onclick="addRows(this)">add</a> 
      </td> 
     </tr> 
     <tr> 
      <td colspan="4" class="darkgray"> 
       <span class="classOverBudget chinese" >Purchase Order Amount is over limited budget.</span> 
      </td> 
      <td class="darkgray" style="text-align:right; font-weight:bold; white-space:nowrap">Total Amount</td> 
      <td class="darkgray" > 
       <asp:TextBox ID="txtTotalAmount" CssClass="classTotalAmount number" Columns="8" runat="server" ></asp:TextBox> 
       <asp:Label ID="Label2" runat="server" CssClass="classCurrency3" /> 
      </td> 
      <td colspan="3" class="darkgray">&nbsp;</td> 
     </tr> 
    </tbody> 
</table> 

function removeRow(name) { 
     if ($("#tblitems tr").length <= 3) return; 
     $(name).parent().parent().remove(); 
     $(".promotion-container").css("height", $("#left").innerHeight() - 42 + "px"); 
     var total= $(name).parent().parent().siblings().find(".classTotalAmount input:textbox").val();   

     alert(total); // only show undefined, not give value 

     $(name).parent().parent().find(".classAmount").each(function() { 
      total -= parseFloat($(this).val());  

     });  

     $(name).parent().parent().find(".classTotalAmount").val(total.toFixed(2)); 

     FormActionControl(); 
    } 

答えて

0

あなたは、レンダリングID

jQuert('#<%=txtTotalAmount.ClientID').val() 

を使用して、それを取得することにより、あなたのテキストボックスの値を取得することができますので、あなたのコードが実行されます

var total= $('#<%=txtTotalAmount.ClientID').val();  
関連する問題