javascript - Adding of dynamically added textboxes values on button click in php -



javascript - Adding of dynamically added textboxes values on button click in php -

i have 2 html tables. in first table able select values required , click on add together button fetches records in first table , appends in sec table. have td in first table consists of combo box on selecting value in combo box , clicking on add together button able append record sec table according values in combo means adding record many times.

i'm having uncertainty that:

i have text box in sec table consists of numeric value, , when selected record first table , add, row gets dynamically appended sec table , textbox added. apart have text box outside these tables. values of textbox in sec tables should added , total should displayed in textbox doesnot belongs these html tables.

the php code sample along jquery follows:

php code

<div> <label>todays date</label> <input type=text name=tdate id=tdate>// used datepicker <input type=button class=addbtn> <table border=1 id=tbl> <tr> <th>sno</th> <th>name</th> <th>date</th> <th>insertion</th> <th>amount</th> </tr> <tr> <td id=num>1</td> <td id=name>abc</th> <td id=date>08-10-2012</td> <td><select id=insertion name=insertion> <?php for($i=1;$i<=10;$i++) { echo "<option value=$i>$i</option>; }?> </select> </td> <td id=amount>10000</td> </tr> <tr> <td id=num>2</td> <td id=name>def</th> <td id=date>23-10-2013</td> <td> <select id=insertion name=insertion> <?php for($i=1;$i<=10;$i++) { echo "<option value=$i>$i</option>; }?> </select> </td> <td id=amount>10000</td> </tr> </table>

// above table info bought database using onchange event of combobox , lots of info

//not showing of now.

<table border = 1 id = clone> <tr> <th>sno</th> <th>name</th> <th>date</th> <th>insertion</th> <th>amount</th> <th>today date</th> <tr> </table> <label>totamount</label> <input type = text name= totamount id=totamount> </div>

functions.js

$('#tbl').on('click', 'tbody tr', function(event) { if ($(this).hasclass('selected')) { $(this).removeclass('selected'); $(this).css("background", "white"); } else { $(this).addclass('selected'); $(this).css("background", "#ffc"); } }); var k=1; $(".addbtn").on('click', function(event) { if ($('#tbl tr').hasclass('selected')) { var items = []; $('#tbl tr.selected').each(function() { var name= $(this).find("#name").html(); var date = $(this).find("#date").html(); var insertion = $(this).find("#insertion option:selected").html(); var amount = $(this).find("#amount").html(); var todaydate = document.getelementbyid("tdate").value; for(var j=1; j<=insertion;j++) { var n = "<tr>"+"<td>"+k+"</td>"+"<td>"+name+"</td>"+ "<td>"+date+"</td>"+"<td>"+j+"</td>"+ "<td>"+amount+"</td>"+"<td>"+todaydate+"</td>"+ "</tr>"; items.push(n); $("#clone").append(n); k++; } }); } $("#tbl tr").removeclass('selected'); $("#tbl tr").css('background','white'); });

// have textbox totamount.

//i want the amount nowadays in clone table added amount in totamount , also

// when click add together button, after selecting tr table (tbl), tr beingness appended

//but amount not added textbox totamount.

and wanted know best way re-create info table , append table.

if not please allow me know other possible way of copying info 1 table other table illustration please.

thanks

please help.

javascript php jquery html dynamic-text

Comments

Popular posts from this blog

c# - ASP.NET MVC Sequence contains no matching element -

java - Parsing XML, skip certain tags -

rest - How to invalidate user session on inactivity in a stateless server? -