Probably something like:
new Element('tr').adopt(
new Element('td').adopt(new Element('input#item_id[type=text]', {name:
'item[][item_id]'})),
new Element('td').adopt(new Element('input#item_id[type=text]', {name:
'item[][item_name]'}))
).inject('myTable');
Like Arieh said you can simply use item[] and it will auto increment.
Otherwise you could use a simple variable which keeps the current index and
increment it each time you inject a new tr element in the table.
On Sun, Dec 19, 2010 at 5:28 PM, אריה גלזר <[email protected]> wrote:
> before we come up with an answer - you should be aware that doing
> item[][item_id]
> will auto increment it
>
>
> On Sun, Dec 19, 2010 at 6:00 PM, lidgold <[email protected]> wrote:
>
>> Hello Arian,
>> thanks for you reply.
>> Actually my problem is a bit more complicated.
>> I have one table with one row and a few input fields, like this:
>>
>> <table id="myTable">
>> <tr>
>> <td><input type="text" id="item_id" name="item[0][item_id]" value=""
>> /></td>
>> <td><input type="text" id="item_name" name="item[0][item_name]"
>> value="" /></td>
>> <tr>
>> </table>
>>
>> I have to create another tr inside #myTable and populate it with td and
>> input fields, while adding 1 to the item.
>> I should end up like this:
>>
>> <table id="myTable">
>> <tr>
>> <td><input type="text" id="item_id" name="item[0][item_id]" value=""
>> /></td>
>> <td><input type="text" id="item_name" name="item[0][item_name]"
>> value="" /></td>
>> <tr>
>>
>> <tr>
>> <td><input type="text" id="item_id" name="item[*1*][item_id]" value=""
>> /></td>
>> <td><input type="text" id="item_name" name="item[*1*][item_name]"
>> value="" /></td>
>> <tr>
>>
>> </table>
>>
>> Have you got any link or example?
>>
>> Thank you.
>>
>
>
>
> --
> Arieh Glazer
> אריה גלזר
> 052-5348-561
> http://www.arieh.co.il
> http://www.link-wd.co.il
>
>