Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to calculate values in tables?

    Say i have a table with the following numbers:

    20 | 30 | 50

    What i want is to automatically calculate cell 1 and cell 2, and give the result in cell 3.
    20+30=50.

    So when i update the numbers in cell 1 and 2, it will automatically update in cell 3.
    Does anybody know of a javascript that can do something like this?
    Or is it easy to make?

    thanks...

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In your function which updates the cells, add the numbers...
    *this message will self destruct in n-seconds*

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the answer.
    but how do i make a function that updates the cells then?

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What cells? I see no cells...
    *this message will self destruct in n-seconds*

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    var 
    AddAry=new Array;
    var 
    add,result;

    function 
    Add(obj){
     if (
    isNaN(obj.value)&&obj.value.charAt(0)!='.'&&obj.value.charAt(0)!='+'&&obj.value.charAt(0)!='-'){
      
    alert('Numbers Please');
      
    obj.value=obj.value.substring(0,obj.value.length-1);
      return;
     }
     
    add=1;
     for (
    i=0;i<AddAry.length;i++){
      if (
    AddAry[i]==obj){
       
    add=0;
      }
     }
     if (
    add){
      
    AddAry[AddAry.length]=obj;
     }
     
    result=0;
     for (
    i1=0;i1<AddAry.length;i1++){
      
    result=result+AddAry[i1].value*1;
     }
     if (!
    isNaN(obj.value)){
      
    document.getElementById('Result').value=result;
     }
    }
    //-->
    </script></head>

    <body>
    <input name="" size="10" onkeyup="javascript:Add(this);">
    <input name="" size="10" onkeyup="javascript:Add(this);">
    <input id="Result" size="10" disabled="disabled">

    </body>

    </html> 

  • #6
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you vwphillips


  •  

    Posting Permissions

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