Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
JavaScript
<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
Posted
Updated 16-Mar-15 20:07pm
v2

1 solution

Following Example will help you

XML
<input name="box1" type="text" /><br />
<input name="box2" type="text" /><br />
<input name="box3" type="text" />

JavaScript
<$('input[name="box2"]').keyup(function() {
    var a = $('input[name="box1"]').val();
    var b = $(this).val();
    $('input[name="box3"]').val(a * b);
});


Happy coding hours ;)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900