I’m doing an Invoice system, and i’m facing a problem.
Imagine a simple Invoice, where you have rows (lines, tuples, whatever) where you place the thing you’re buying, the amount, the price, etc.
So, in my script i’ve a form like this:
<form action='I-process-the-form-but-not-see-data.php'>
<input ... //some other imputs (client,date,etc)
<table>
//table hedaers
<tr>
<td><input type='text' name='invoiceData[0][name]' /></td>
<td><input type='text' name='invoiceData[0][amount]' /></td>
<td><input type='text' name='invoiceData[0][price]' /></td>
</tr>
</form>
I provide a button that adds a line to the invoice. I’m doing it with JQuery.
I first get the first and clone it. Replace invoiceData[0] with invoiceData[COUNTER] (Global counter) and everything looks great.
The problem is that my data is not being sent to the php script. The only data i get is the inputs that are static (first loaded). Not the one that i add with jquery.
I’ve inspect it with firebug and it’s adding the new lines ok.
Actually, if i paste the code generated by JQuery in the static form it sends it well.
What could be happening?
EDIT (JQUERY MAGIC):
var clon = $("#selectorForTR").clone().html(); //there is a minimal workaround for this but doesn't matters
clon = $(html.replace(/invoiceData\[0\]/ig, "invoiceData["+contador+"]"));
$("#tableBody").append(clon);
Make sure you are opening and closing your cloned tr, i think that is why it is only getting one row.
See my example : http://jsfiddle.net/wADef/
Changed it a bit to work in jsFiddle, but check it out and let me know.