I am creating a dynamic form in which the user can add elements dynamically. I am able to allow them to add text boxes however I'm not sure how to add my drop down menu into it. Here is my jQuery code
var addDiv2 = $('#addIngredient');
var i = $('#addIngredient p').size() + 1;
$('#addNewIngredient').on('click', function () {
$('<p> <input id="ingredient_' + i + '" name="ingredient[]" type=text"
value="" placeholder="Ingredient" />
<input id="quantity_' + i + '"
name="quantity[]" type=text" value="" placeholder="Quantity" />
<input id=alternative_' + i + '" name="alternative[]" type=text"
value"" placeholder="Alternative Ingredient" />
<a href=#" class="remNew2"> Remove </a> </p> ').appendTo(addDiv2);
Here is my html
<div id="addIngredient">
<p>
<input type="text" id="ingredient_1" name="ingredient[]" value=""
placeholder="Ingredient"/>
<input type="text" id="quantity_1" name="quantity[]" value=""
placeholder="Quantity"/>
<input type="text" id="alternative_1" name="alternative[]" value=""
placeholder="Alternative Ingredient"/>
<select id="selectQuantity_1" name="quantityType[]">
<option value="grams">Grams</option>
<option value="ounces">Ounces</option>
<option value="Pounds">Pounds</option>
</select>
<a href="#" id="addNewIngredient">Add</a>
I have tried but can't work it out, help would be appreciated!
Here is the jsFiddle http://jsfiddle.net/3yFFr/
ignore the bit below the jQuery i pasted, i had to paste it all in for it to work.