在asp.net中的标签上获取javascript函数值 [英] get javascript function value on label in asp.net

查看:62
本文介绍了在asp.net中的标签上获取javascript函数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生.
我有两个文本框TxtA,TxtB.我正在使用javascript函数计算这些文本框的总和.我在页面上有一个标签.我想在标签上显示总和值.该怎么做.
我的JavaScript函数如下.

hello sir.
i have two text boxes TxtA, TxtB. i am calaculating sum of these text boxes using javascript function. i have a label on a page. i want to display the sum value on label. how to do this.
my javascript function is below.

<script type ="text/javascript" >
        function fun() {
            var a = document.getElementById("TxtA").value;
            var b = document.getElementById("TxtB").value;
            var sum = parseInt(a) + parseInt(b);
            //alert(sum);

        }
    </script>



没有警报,我想在标签上显示此值.
任何身体请帮助我.
谢谢.



with out alert i want to display this value on label.
any body plz help me.
thanking you.

推荐答案

document.getElementById("Label1").innerText=sum;
//or

document.getElementById("Label1").innerhtml=sum;


希望 ^ ]和 [
Hope this[^]and this[^] might help you.


可以得到结果,但在每次回发中,这些标签文本均已清除.怎么发生的,请解决我的问题.
It ok to get the the result, but in every postback these lable text cleared. how it is happen, pls clear my problem.


这篇关于在asp.net中的标签上获取javascript函数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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