2012-11-09 49 views
0

你好,我有一個Repeater控件更新中繼文本框與另一個文本框的keyup事件

<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?

回答

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> 
+0

以及如何將它設置爲另一個文本框? – Moiz

+0

,我沒有得到這個價值。 – Moiz

+0

它不工作。它在相同的模板中,甚至沒有發生。 – Moiz

相關問題