So I'm sorry the title is so vague I'm not really even sure how to word this question in just a few words.
So I have a form for adding items to a webstore. Within that form is the option to add different varieties of a product, say different sizes or colors for clothing, etc...
I wanted to only offer a field for the first variety onload, then have an 'add' button to display an additional field for each further desired variety.
After you click the add button, the old add button becomes a subtract button, and a new input field as well as a new add button are appended to the previous.
I'd like this process to work continuously.
When adding the first new field, the process works perfectly, however, adding additional elements do not work as expected. The new fields are added as well as new add buttons, however the old add buttons are not converted to subtract buttons. I'm really not sure what the issue is here. I'm not exactly a jquery wizard.
Here's the relevant part of the form:
<label for="varieties">Varieties</label><input type="text" name="varieties[]" id="varieties1" value="Default" /> <a href="#" class="add-variety"><img src="../img/plus.png" alt="Add" title="Add Another Variety" /></a><br />
And here's the jquery that i've written:
$('a.add-variety').click(function() {
$(this).removeClass('add-variety');
$(this).addClass('subtract-variety');
$(this).append('<br /><input type="text" name="varieties[]" value="Default" /> <a href="#" class="add-variety"><img src="../img/plus.png" alt="Add" title="Add Another Variety" /></a>');
$(this).children('img').attr('src','../img/minus.png');
return false;
});
Thanks so much for any help!