通过计算其他文本框值将文本插入文本框使用Javascript [英] insert text to Textbox by calucating another textboxes values use Javascript

查看:87
本文介绍了通过计算其他文本框值将文本插入文本框使用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个文本框包含int值和其他文本框(计算),它应该通过在这几个文本框中使用if else进行求和数学运算得到该值,并出现在此计算文本框中。



每当我们更改这些文本框中的值时,该值应在计算文本框中自行更改..



any一个可以帮助请

解决方案

请参阅 onchange事件 [ ^ ]


< script language =javascripttype =text / javascript>



 function functn(){
var a = document.getElementById('text1')。value;
var b = document.getElementById('text2')。value;
if(a ==)
a = 0;
if(b ==)
b = 0;

var res = parseInt(a)+ parseInt(b);

document.getElementById('text3')。value = res;

< / script>



< input type =textvalue =text1>

< input type =textvalue =text2onblur =functn()>

<< input type =textvalue =text3 >< /输入>


hi, i have few text boxes contains int values and other text box(calculation) which should get the value by doing sum mathematical operation using if else on those few text boxes and present in this calculation text box..

whenever we change values in those text boxes the value should change by itself in calculation text box..

any one can help please

解决方案

See onchange Event[^]


<script language="javascript" type="text/javascript">

       function functn() {
           var a = document.getElementById('text1').value;
           var b = document.getElementById('text2').value;
           if (a == "")
               a = 0;
           if (b == " ")
               b = 0;

           var res = parseInt(a) + parseInt(b);

document.getElementById('text3').value = res;

</script>

<input type="text" value="text1">
<input type="text" value="text2" onblur="functn()" >
<<input type="text" value="text3" ></input>


这篇关于通过计算其他文本框值将文本插入文本框使用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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