Server IP : 162.240.98.243 / Your IP : 3.21.244.217 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title> Adding new textbox values </title> <script type="text/javascript"> function addRowToTable(){ var tbl = document.getElementById('tblSample'); var frm=document.form0; if (!frm.ary) frm.ary=[frm.t1_2]; var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var cellLeft = row.insertCell(0); var textNode = document.createTextNode(iteration); cellLeft.appendChild(textNode); var cellRight1 = row.insertCell(1); var el1 = document.createElement('input'); el1.type = 'text'; el1.name = 't' + iteration + '_1'; el1.id = 't' + iteration + '_1'; el1.size = 40; cellRight1.appendChild(el1); var cellRight2 = row.insertCell(2); var el2 = document.createElement('input'); frm.ary.push(el2); el2.type = 'text'; el2.value = ''; el2.name = 't' + iteration + '_2'; el2.id = 't' + iteration + '_2'; el2.size = 5; el2.onkeyup=Calc; el2.onblur=Calc; cellRight2.appendChild(el2); } </script> <script type="text/javascript"> function Calc(){ var frm=document.form0; if (!frm.ary) frm.ary=[frm.t1_2]; var total=0; for (var zxc0=0;zxc0<frm.ary.length;zxc0++){ if (frm.ary[zxc0].value.length>0&&!isNaN(frm.ary[zxc0].value)) total+=frm.ary[zxc0].value*1; } frm.sum.value=total; } </script> </head> <body> <form action="none" method="get" name="form0" id="form0"> <table border="0" id="tblSample" align="center"> <tr> <th colspan="3"><br><br><br>Adding rows then adding up values entered<hr> <input type="button" value="Add new textbox" onclick="addRowToTable();"></th> </tr> <tr id="cloneid" > <td> 1 Name / Price </td> <td> <input type="text" name="t1_1" id="t1_1" size="40"> </td> <td> <input type="text" name="t1_2" id="t1_2" size="5" value="" onkeyup="Calc();" onblur="Calc();"></td> </tr> </table> <table border="0" align="center"> <tr> <td colspan="3" align="center"><br><br> Sum: <input type="text" name="sum" id="sum"><br><br> </td> </tr> </table> </form> </body> </html>