Results 1 to 10 of 10

Thread: Sum of text boxes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    182

    Sum of text boxes

    I have 4 text boxes in a colmn and a total box at the end. The total box will be the sum of the values in textboxes 1-4. How do I get the total box to sum when alues are added or changed in any of the four boxes?

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Sum of text boxes

    Originally posted by realgoldn
    I have 4 text boxes in a colmn and a total box at the end. The total box will be the sum of the values in textboxes 1-4. How do I get the total box to sum when alues are added or changed in any of the four boxes?
    Use javascript and write a function to AddUP the values of four text box. Use the OnChange event of each text box to update the calculation by calling the AddUP function.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    182
    Is there a way to have a group name for a group of text boxes. So I can say on change event of the group then call addup() or must I reference each textbox separatly cuase I have over 20 of them.

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by realgoldn
    Is there a way to have a group name for a group of text boxes. So I can say on change event of the group then call addup() or must I reference each textbox separatly cuase I have over 20 of them.
    No you cant group them, it wouldnt be much anyway just an extra line for each text box.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    182
    For some reason it is treating the value as a string not a number becuase the two values I want to add are 200 + 600 which is 800 but it is displau 200600. Help! This is the function!

    sub AddUPEQP()
    SET Add = document.Addproj
    EQPTotal=add.txteqp1.value
    EQPTotal=EQPTotal+add.txteqp2.value
    add.txtEQP14.value=EQPTotal
    end sub

  6. #6
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by realgoldn
    For some reason it is treating the value as a string not a number becuase the two values I want to add are 200 + 600 which is 800 but it is displau 200600. Help! This is the function!

    sub AddUPEQP()
    SET Add = document.Addproj
    EQPTotal=add.txteqp1.value
    EQPTotal=EQPTotal+add.txteqp2.value
    add.txtEQP14.value=EQPTotal
    end sub
    Use Val()........

    VB Code:
    1. sub AddUPEQP()
    2.     SET Add = document.Addproj
    3.     EQPTotal=val(add.txteqp1.value)
    4.     EQPTotal=EQPTotal+val(add.txteqp2.value)
    5.     add.txtEQP14.value=EQPTotal
    6. end sub
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    182
    Is it possible to call two different functions on the onchange() like this

    onchange(addup(),totalup())??? Becuase I want to add the totals down and across so I need to different functions.

  8. #8
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by realgoldn
    Is it possible to call two different functions on the onchange() like this

    onchange(addup(),totalup())??? Becuase I want to add the totals down and across so I need to different functions.
    Never tried it, it wouldnt be advised to do so. Have another function which call those to function, and call that function instead.

    eg.

    function myUpdate()
    addup();
    totalup()
    end function

    now simply call myUpdate.

    Hope this helps.

    Danial
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    182
    Thanks!

  10. #10
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by realgoldn
    Thanks!
    You are welcome.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width