jquery loop to create elements

Posted by Andy Simpson on Stack Overflow See other posts from Stack Overflow or by Andy Simpson
Published on 2010-03-30T15:17:43Z Indexed on 2010/03/30 15:23 UTC
Read the original article Hit count: 462

Filed under:
|

Dear all, I have had no luck with this task so far so grateful for any help.

I have an html form, in which there is a small select menu (1-10) ie

<select>
    <option value = '1'>1</option>
    <option value = '2'>2</option>
    ...
    <option value = '10'>10</option>
</select>

depending on what value is selected i would like jquery to create (or remove) that number of input text boxes (with different names and id's). eg if 2 was selected these inputs would be created:

<input type = 'text' name = 'name1' id = 'id1' />
<input type = 'text' name = 'name2' id = 'id2' />

i look forward to your no doubt simple and elegant solutions! andy

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about loops