Forums

Adding form elements dynamically using jQuery

guimplenchik 15 May, 2010
Hi,

I am working on dynamically changing form elements (basically, adding/deleting additional fields) using jQuery. Seems like I am on half my way to get it done.

Here is the pseudo code example.. So I have the following:
<div id="input1">
 <input id="item1" name="item1" type="text" .... />
 <input id="link1" name="link1" type="text" .... />
 <input id="description1" name="description1" type="text" .... />
</div>


when I press 'Add extra fields' button, script duplicates above div, but with different IDs and names like input2,item2,link2,description2, etc..

Unfortunately, I can't figure out how to handle Email template with dynamic IDs and Names. Anyone do this before?

Thank you
GreyHead 15 May, 2010
Hi guimplenchik,

I'd probably use array names in the dynamic fields then generate the template using PHP to check the array length and generate the template to match the results.

Bob
guimplenchik 15 May, 2010
hi,

how I'm supposed to generate the template? Where can I read about it?
This topic is locked and no more replies can be posted.