我想获得
的价值<asp:TextBox ID="txtTotalAmount" CssClass="classTotalAmount number" Columns="8" runat="server"></asp:TextBox>
来自表格。
在aspx文件中:
<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"> </td>
</tr>
</tbody>
</table>
在jQuery中:
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 :(得分:0)
您可以使用呈现的ID
获取文本框的值jQuert('#<%=txtTotalAmount.ClientID').val()
所以你的代码将完成
var total= $('#<%=txtTotalAmount.ClientID').val();