根据在文本框one.or textbox two中输入的值自动填充文本框。 [英] Auto fill text box based on the value entered in textbox one.or textbox two.

查看:63
本文介绍了根据在文本框one.or textbox two中输入的值自动填充文本框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框。



例如,如果我在第一个文本框中输入类似20的值,它应该自动填充另一个文本框80,两个文本框的限制是100,



并假设如果我在第二个文本框中输入50这样的值,首先应填写50,



怎么办..?

任何帮助??



我是什么尝试过:



开始编写代码,请提出任何建议

I have two text boxes.

for example if i enter a value like 20 in first text box it should auto fill another text box with 80,, the limit of two text boxes is 100,

and suppose if i enter a value like 50 in 2nd text box, first should fill with 50,,

how to do..?
any help??

What I have tried:

Started writing the code,, please give any suggestions

推荐答案

<asp:TextBox onchange="funchange(this)" ID="TextBox1" runat="server"></asp:TextBox>
         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>







<script src="jquery.min.js"></script>
    <script>
        function funchange(obj)
        {
            var value = obj.value;
            if (


.isNumeric(value))
{
var result = parseInt (value);
结果= 100-结果;
document .getElementById(' <% = TextBox2.ClientID%>')。value = result;
}


}
< / script >
.isNumeric(value)) { var result = parseInt(value); result = 100- result; document.getElementById('<%= TextBox2.ClientID %>').value = result; } } </script>





参考

onchange Event [ ^ ]

JavaScript parseInt()函数 [ ^ ]

jQuery.isNumeric()| jQuery API文档 [ ^ ]





注:注意验证。



refer
onchange Event[^]
JavaScript parseInt() Function[^]
jQuery.isNumeric() | jQuery API Documentation[^]


Note: Take care of the validations.


这篇关于根据在文本框one.or textbox two中输入的值自动填充文本框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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