自动添加文本框 [英] Automatically adding of text boxes

查看:88
本文介绍了自动添加文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员,这里有问题.如您所见,我想要的就是自动添加存储在所有文本框中的所有vlues.香港专业教育学院尝试了许多方法,包括将textmaterial2 autopostbact设置为true并将解决方案放在txtTE2上,但仍然无法正常工作.我不知道我的Java脚本是否正确.请帮助.这里有什么可能的解决方法吗?

hello programmers, got a problem here. As you see all i want is to automatically add all the vlues stored on all the text boxes. Ive tried many ways including setting textmaterial2 autopostbact to true and put the solution on txtTE2 but still it doesnt work. I dont know if my java script is correct. Plss help. Is there any possible solution here?

<script language="javascript">
function keyUp() {
            if (document.getElementById("txtmaterial2").value == "") {
                document.getElementById("txtTE2").text == "";
            }
            else {
                document.getElementById("txtTE2").text = Round((CDbl(txtmealallowance2.Text) + CDbl(txttransportationallowance2.Text) + CDbl(txtPerDiem2.Text) + CDbl(txttransportation2.Text) + CDbl(txtaccomodation2.Text) + CDbl(txtmealven2.Text) + CDbl(txtconsultant2.Text) + CDbl(txtmaterial2.Text)), 2);
            }
        }
</script>

推荐答案

CDbl是vbscript函数
您正在调用的javascript中是否有任何自定义设计的函数"CDbl"?

一些提示:

1.使用jquery使用javascript简化生活.
2.如果使用IE打开开发人员栏(firefox中的萤火虫)并调试javascript,则可以轻松看到错误.
CDbl is a vbscript function
do you have any custom designed function ''CDbl'' in your javascript that you are calling?

some tips:

1. Use jquery to make your life simpler in javascript.
2.if using IE open developer bar (firebug in firefox) and debug your javascript, you can easily see your error.


尝试以下代码:
Try this code:
<script language="javascript">
function sumquinto()
{
var Sumbog=0;
var val1= parseInt(document.getElementById("textbox1").value);
var val2= parseInt(document.getElementById("textbox2").value);
var val3= parseInt(document.getElementById("textbox3").value);
var val4= parseInt(document.getElementById("textbox4").value);
var val5= parseInt(document.getElementById("textbox5").value);
var val6= parseInt(document.getElementById("textbox6").value);
etc


if (val1 >=0)
{
Sumbog= Sumbog + val1
}
if (val2>=0)
{
Sumbog=Sumbog+val2
}
if (val3>=0)
{
Sumbog=Sumbog+val3
}
if (val4>=0)
{
Sumbog=Sumbog+val4
}
if (val5>=0)
{
Sumbog=Sumbog+val5
}
if (val6>=0)
{
etc
}
document.getElementById("txtTE2").value=Sumbog
}
</script>
<asp:TextBox ID="TextBox1" runat="server" onkeyup="sumquinto();"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onkeyup="sumquinto();"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" onkeyup="sumquinto();"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server" onkeyup="sumquinto();"></asp:TextBox>


并且在您的解决方案文本框中不要添加onkeyup事件.


and on your solution textbox dont add the onkeyup event.




试试这个:

Hi,

Try this:

function keyUp() {
        var mealallowance2 =


这篇关于自动添加文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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