Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table,td
- {
- border:1px solid #393;
- }
- </style>
- </head>
- <body>
- <p>Click the buttons to create and delete row(s) for the table.</p>
- <table id="myTable">
- <tr>
- <td>No</td>
- <td>Description</td>
- <td>Unit Price</td>
- <td>Quantity</td>
- <td>Amount</td>
- <td>Delete row</td>
- </tr>
- <tr>
- <td><input type="text" size = "2" name="no" placeholder=" No" ></td>
- <td><input type="text" name="description" placeholder=" Description" ></td>
- <td><input type="text" name="unit_price" placeholder=" Unit Price" ></td>
- <td><input type="text" name="quantity" placeholder=" Qty" ></td>
- <td><input type="text" name="amount" placeholder=" Amount" ></td>
- <td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
- </tr>
- </table><p>
- <hr></hr>
- <button onclick="myCreateFunction()">Create row</button>
- <script>
- function myCreateFunction()
- {
- var table = document.getElementById("myTable");
- {
- var a = '';
- var b = '';
- var c = '';
- var d = '';
- var e = '';
- for(var i = 1; i <= 1; i++)
- {
- a += '<input type="text" name="no'+i+'" placeholder=" No'+i+'" >';
- b += '<input type="text" name="description'+i+'" placeholder=" Description'+i+'" >';
- c += '<input type="text" name="unit_price'+i+'" placeholder=" Unit Price'+i+'" >';
- d += '<input type="text" name="quantity'+i+'" placeholder=" Qty'+i+'" >';
- e += '<input type="text" name="amount'+i+'" placeholder=" Amount'+i+'" >';
- f += '<input type="button" name = "delete '+i+'" value="Delete'+i+'" onclick="deleteRow(this)'+i+'">';
- }
- var row = table.insertRow(-1);
- var cell1 = row.insertCell(0);
- var cell2 = row.insertCell(1);
- var cell3 = row.insertCell(2);
- var cell4 = row.insertCell(3);
- var cell5 = row.insertCell(4);
- var cell6 = row.insertCell(5);
- cell1.innerHTML = a;
- cell2.innerHTML = b;
- cell3.innerHTML = c;
- cell4.innerHTML = d;
- cell5.innerHTML = e;
- cell6.innerHTML = f;
- }
- }
- function deleteRow(r)
- {
- var x = r.parentNode.parentNode.rowIndex;
- document.getElementById("myTable").deleteRow(x);
- }
- </script>
- </body>
- </html>
- <table>
- <tr>
- <td><input type="text" onblur="calcTotal(this, 'tot')" /></td>
- <td><input type="text" onblur="calcTotal(this, 'tot1')" /></td>
- </tr>
- <tr>
- <td><input type="text" onblur="calcTotal(this, 'tot')" /></td>
- <td><input type="text" onblur="calcTotal(this, 'tot1')" /></td>
- </tr>
- <tr>
- <td><input type="text" onblur="calcTotal(this, 'tot')" /></td>
- <td><input type="text" onblur="calcTotal(this, 'tot1')" /></td>
- </tr>
- <tr>
- <td><input type="text" id="tot" /></td>
- <td><input id="tot1" type="text" /></td>
- </tr>
- </table>