Sharma Raushan

Sharma Raushan

  • NA
  • 527
  • 15.2k

Find all input fields and add values (sum of quantity and price)

Nov 15 2020 3:23 AM
I have below HTML table, on Add to table click a new is added each time with price and quantity input fields, how to sum all on Sum() click.
  1. <button onclick="AddToTable()">Add to Table</button>    
  2. <button onclick="Sum()">get Invoice</button>    
  3. <table id="table" class="table table-bordered">    
  4.     <thead>    
  5.         <tr>    
  6.             <td>Quantity</td>    
  7.             <td>Price</td>    
  8.     
  9.         </tr>    
  10.     </thead>    
  11.    <tbody>    
  12.     
  13.    </tbody>    
  14. </table>    
  15. function AddToTable()  
  16. {  
  17. var trr = document.createElement("tr");  
  18. $(trr).append("<td>" + "<input type='text'/>" + "</td>").append("<td>" + "<input type='text'/>" + "</td>");  
  19. $("#table tbody").append(trr);  
  20. }  
 

Answers (1)