Save dynamically created fields in MYSQL databse
Dear All
I want to save fields that are created dynamically
- <table width="100%" class="table table-bordered" id='invoicetable'>
- <thead>
- <tr>
- <th width="5%"><h4 align="center">NO</h4></th>
- <th width="50%">
- <h4>Perticuler
- <label for="numberofrows"></label>
- <input name="numberofrows" type="text" id="numberofrows" value="1" />
- </h4> </th>
- <th width="15%">
- <h4 align="center">Hrs/Qty</h4> </th>
- <th width="15%">
- <h4 align="center">Rate/Price</h4> </th>
- <th width="15%">
- <h4 align="center">Sub Total</h4> </th>
- <th width="15%"><input type="button" value="Add Fild" id='addfield' class="AddButton" ></th>
-
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><div align="center">1</div></td>
- <td><input name="particular1" type="text" id="particular1" class="particular"></td>
- <td class="text-right"><div align="center"><input name="qty1" type="text" id="qty1" class="qty" value="0.00"></div></td>
- <td class="text-right"><div align="center"><input name="rate1" type="text" id="rate1" class='rate' value="0.00"></div></td>
- <td class="text-right"><div align="center"><input name="subtotal1" type="text" id="subtotal1" class='subtotal' value="0.00"></div></td>
- <td class="text-right"> </td>
- </tr>
- </tbody>
- </table>
AddButton creates a row using following Jquerry
- $(document).ready(function() {
- $(".AddButton").live("click", function(e) {
- var rowCount = $('#invoicetable tr').length;
-
- var numberofrows=$('#numberofrows').val();
- // alert(numberofrows);
- var numberofrows = parseInt(numberofrows) + 1;
- // alert(numberofrows);
- $('#numberofrows').val(numberofrows);
-
- // alert('aa'+rowCount);
- $("#invoicetable > tbody").append('<tr> <td><div align="center">'+rowCount+'</div></td> <td><input name="particular'+rowCount+' type="text" id="particular'+rowCount+'" class="particular" ></td> <td class="text-right"><div align="center"><input name="qty'+rowCount+' type="text" id="qty'+rowCount+'" class="qty" value="0.00"></td> <td class="text-right"><div align="center"><input name="rate'+rowCount+' type="text" id="rate'+rowCount+'" class="rate" value="0.00"></div></td> <td class="text-right"><div align="center"><input name="subtotal'+rowCount+' type="text" id="subtotal'+rowCount+'" class="subtotal" value="0.00"></div></td><td></td> </tr>');
- $('#invoicetable > tbody:last').append(newRow);
-
- });
In short I am creating following fields dynamically using jquery given above
particula2
particula4
qty2
qty3
qty4
rate2
rate3
rate4
However when i click Submit to save records
I am unable to save these fields
I tried
- echo "<br>part >> ".$_POST['particular2'].' '.$_POST['particular3'].' '.$_POST['particular4'];
- echo "<br>qty 234 >>".$_POST['qty2'].' '.$_POST['qty3'].' '.$_POST['qty4'];
- echo "<br> rate 234 ".$_POST['rate2'].' '.$_POST['rate3'].' '.$_POST['rate4'];
- echo "<br> sunbtotal ".$_POST['subtotal2'].' '.$_POST['subtotal3'].' '.$_POST['subtotal4'];
But nothing was stored in the fields