开发者

Problems with Dynamic fom with JQuery and PHP

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 gene开发者_开发技巧rated 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.

<tr> ...html... </tr>

See my example : http://jsfiddle.net/wADef/

Changed it a bit to work in jsFiddle, but check it out and let me know.


Are you certain that you are appending the generated html in the right place? ie, inside the form tag? If the data isn't coming through, that's the only thing I can think of immediately! :]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜