I have an HTML form consisting of several fields (each has the same fields). I want users to be able to add additional fields by clicking the (jQuery) button. I can imagine two approaches:
Create a dummy hidden set of fields and clone it when you click the add button.
Create a function that displays HTML code in a field from a string when you click the add button. (The function knows the set of fields as a long string.)
Are there any significant advantages or disadvantages that can be applied? Is there another way?
I donβt like the idea that the dangling widget is around, even if it is hidden, but encodes the entire set of fields as a string, it seems a little unthinkable, although I know that this is a fairly standard practice.
source
share