本文介绍了在javascript中乘以文本框的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< script type = text / javascript src = http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min。 JS跨度>>< /脚本>
< script type = text / javascript>
$( function (){
var textBox1 = $(' input:text [id $ = FreightCharge]')。keyup(foo);
var textBox2 = $(' input:text [id $ = FuelSurcharge] ')。keyup(foo);
var textBox3 = $(' input:text [id $ = FOV]')。keyup(foo);
var textBox4 = $(' input:text [id $ = COD]')。keyup(foo);
var textBox5 = $(' 输入: text [id $ = FOD]')。keyup(foo);
var textBox6 = $(' input:text [id $ = PickupCharge]')。keyup(foo);
var textBox7 = $(' 输入:文本[ID $ = DoorDelivery]'跨度>)KEYUP(富)。
var textBox8 = $(' 输入:文本[ID $ =处理]'跨度>)KEYUP(富)。
var textBox9 = $(' 输入:文本[ID $ =杂项]'跨度>)KEYUP(富)。
var textBox10 = $(' 输入:文本[ID $ = DktCharge]'跨度>)KEYUP(富)。
function foo(){
var value1 = textBox1。 VAL();
var value2 = textBox2.val();
var value3 = textBox3.val();
var value4 = textBox4.val();
var value5 = textBox5.val();
var value6 = textBox6.val();
var value7 = textBox7.val();
var value8 = textBox8.val();
var value9 = textBox9.val();
var value10 = textBox10.val();
var sum = add(value1,value2,value3,value4,value5,value6,value7,value8,value9,value10);
$(' input:text [id $ = SubTotal]')。val(sum );
}
function add(){
var sum = 0 ;
for ( var i = 0 ,j = arguments.length; i< j; i ++){
if (IsNumeric(arguments [i])){
sum + = parseFloat (arguments [i]);
}
}
返回 sum;
}
function IsNumeric(输入){
return (输入 - 0 )==输入&& input.length> 0 ;
}
});
我想要的是我在11个文本框中总共有10个文本框我想要繁殖* 12.36的11个文本框将其值放在12textbox中,并将13和12文本框的总和放在13个文本框中。是否有任何方式
解决方案
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function () { var textBox1 = $('input:text[id$=FreightCharge]').keyup(foo); var textBox2 = $('input:text[id$=FuelSurcharge]').keyup(foo); var textBox3 = $('input:text[id$=FOV]').keyup(foo); var textBox4 = $('input:text[id$=COD]').keyup(foo); var textBox5 = $('input:text[id$=FOD]').keyup(foo); var textBox6 = $('input:text[id$=PickupCharge]').keyup(foo); var textBox7 = $('input:text[id$=DoorDelivery]').keyup(foo); var textBox8 = $('input:text[id$=Handling]').keyup(foo); var textBox9 = $('input:text[id$=Misc]').keyup(foo); var textBox10 = $('input:text[id$=DktCharge]').keyup(foo); function foo() { var value1 = textBox1.val(); var value2 = textBox2.val(); var value3 = textBox3.val(); var value4 = textBox4.val(); var value5 = textBox5.val(); var value6 = textBox6.val(); var value7 = textBox7.val(); var value8 = textBox8.val(); var value9 = textBox9.val(); var value10 = textBox10.val(); var sum = add(value1, value2, value3, value4, value5, value6, value7, value8, value9, value10); $('input:text[id$=SubTotal]').val(sum); } function add() { var sum = 0; for (var i = 0, j = arguments.length; i < j; i++) { if (IsNumeric(arguments[i])) { sum += parseFloat(arguments[i]); } } return sum; } function IsNumeric(input) { return (input - 0) == input && input.length > 0; } });
What I want to is I have sum of 10 textboxes in the 11 textbox I want to multiply the 11 textbox by *12.36 put its value in the 12textbox and the sum of 11 and 12 textbox in the 13 textbox. is there any way
解决方案
这篇关于在javascript中乘以文本框的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!