0

您好,我有一个中继器控件

<asp:Repeater ID="rptCashCome" runat="server">
    <ItemTemplate>
           <asp:TextBox ID="txtCurrencyNo" onkeyup="javascript:CallFunction()" CssClass="mws-textinput" runat="server"></asp:TextBox>
           <asp:TextBox ReadOnly="True" ID="txtTotal" CssClass="mws-textinput" runat="server"></asp:TextBox>

     </ItemTemplate>
     </asp:Repeater>

我有一个 Jquery 函数

function CallFunction() {

//code here i want something like. txtCurrencyNo* 500 = txtTotal
// something like calculative here. but how will i find the Control ID of repeater ?



 }

这个函数被调用。但是我如何根据文本框 KeyUp 进行计算?我如何在这里找到控件 ID?

4

1 回答 1

0

您可以为此使用 jQuery。
采用

$(this).val()

它将为您提供当前文本框的值。
如果另一个文本框在同一个模板中,那么您可以像这样使用(未经测试)

function CallFunction() {
    var firstTextBoxVal= $(this).val();
    $(this).next().val(firstTextBoxVal* 500 )
}

如下更改中继器

<asp:Repeater ID="rptCashCome" runat="server">
<ItemTemplate>
       <asp:TextBox ID="txtCurrencyNo" onkeyup="javascript:CallFunction(this)" CssClass="mws-textinput" runat="server"></asp:TextBox>
       <asp:TextBox ReadOnly="True" ID="txtTotal" CssClass="mws-textinput" runat="server"></asp:TextBox>

 </ItemTemplate>
 </asp:Repeater>
于 2012-11-09T10:46:28.020 回答