Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <table>
    <tr>
      <td>Rate;</td>
      <td><input class="amount" type="text" value="50.0" /></td>
    </tr> 
    <tr>
  
      <td>Rate;</td>
      <td><input class="amount" type="text" value="30.0" /></td>
    </tr> 
     <tr>
  
      <td>Rate;</td>
      <td><input class="amount" type="text" value="30.0" /></td>
    </tr> 
     <tr>
  
      <td>Rate;</td>
      <td><input class="amount" type="text" value="30.0" /></td>
    </tr> 
  </table>
  <input type="text" name="tot" id="s" onclick="getTotal()" value="click for total" />
</body>
</html>
 
function getTotal() {
  var inputs = document.getElementsByTagName('input'), el, total = 0;
  
  for (var i = 0, n = inputs.length; i < n; i++) {
    el = inputs[i];
    if (el.className == "amount") {
      total += +el.value;
    }
  }
  
  document.getElementById('s').value = total;
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers