user1598482
user1598482

Reputation:

How to dynamically add input fields to a form

I'm currently working with Asset Management system. The company is spread through out different locations.

This system can return asset items to store again if these items are not in use.

What I want to do is return the item there are lots of items. So I have input fields like this:

<td><input type="text" name="asset_id[]"/></td>
<td><input type="text" name="batch_code[]"/></td>
<td><input type="text" name="description[]"/></td>
<td><input type="text" name="status[]"/></td>
// current condition of the item

I can't use these fields again and again, I don't know how many fields are required for each particular situation.

If I can give an option to the user to add input fields if he/she needs, how do I do this.

Upvotes: 1

Views: 3399

Answers (2)

Damian SIlvera
Damian SIlvera

Reputation: 866

Here you can see something like that http://jsfiddle.net/damian_silvera/ATzne/

Upvotes: 2

Rosmarine Popcorn
Rosmarine Popcorn

Reputation: 10967

Using JS/jQuery propably :

HTML :

   <a href="#" id="plus_row">Add Row</a>

jQuery

$(document).ready(function(){
   $("a#plus_row").click(function(){
     $("table#form_table").append($("table#form_table").find('tr').get(0));
   });
});

Upvotes: 0

Related Questions