使用jquery更改文本中的转发器中的html文本框的总和 [英] sum of html text boxes in repeater on text change using jquery

查看:72
本文介绍了使用jquery更改文本中的转发器中的html文本框的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在转发器中有两个HTML文本框。在那些文本框的文本更改中,我想使用JQuery在第3个HTML文本框中进行求和。



我怎样才能实现它?



谢谢,

KK

解决方案

下面是示例代码



ASPX代码



 <   html     xmlns   =  http://www.w3.org/1999/xhtml >  
< head runat = server >
< title > 无标题页< / title >

< script src = Scripts / jquery-1.4.1.min.js 类型 = text / javascript > < / script > ;

< / head >
< body >
< 表格 < span class =code-attribute>
id = form1 runat = server >
< div >
< asp:Repeater ID = Repeater1 runat = server >
< ItemTemplate >
< div >
< asp:TextBox ID = TextBox1 runat < span class =code-keyword> = server 文本 = 0 / >
< asp:TextBox ID = TextBox2 runat = server 文字 = 0 / >
< asp:TextBox ID = TextBox3 runat = 服务器 / >
< / div >
< / ItemTemplate >
< / asp:Repeater >
< / div >

< 脚本 >

函数GetTotalAmount(obj){
var txtbox1id = obj.id.replace('TextBox2 , 'TextBox1中');
var txtbox2id = obj.id.replace('TextBox1','TextBox2');
var txtbox3id = obj.id.replace('TextBox1','TextBox3')。replace('TextBox2','TextBox3');
var total = parseFloat(


('#'+ txtbox1id).val())+ parseFloat(


('#' + txtbox2id).VAL());

hi all,

i have two HTML text boxes inside repeater. on text change of those text box i want to do sum and display in 3rd HTML text box using JQuery.

how can i achieve it?

Thanks,
KK

解决方案

Below is sample code

ASPX code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <div>
                <asp:TextBox ID="TextBox1" runat="server" Text=0 />
                <asp:TextBox ID="TextBox2" runat="server" Text=0 />
                <asp:TextBox ID="TextBox3" runat="server" />
            </div>
        </ItemTemplate>
    </asp:Repeater>
    </div>

    <script>

     function GetTotalAmount(obj){
          var txtbox1id = obj.id.replace('TextBox2','TextBox1');
          var txtbox2id = obj.id.replace('TextBox1','TextBox2');
          var txtbox3id = obj.id.replace('TextBox1','TextBox3').replace('TextBox2','TextBox3');
            var total =parseFloat(


('#'+ txtbox1id).val()) +parseFloat(


('#'+txtbox2id).val());


这篇关于使用jquery更改文本中的转发器中的html文本框的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆