I have a control with 2 textboxes and a select box in one row. The user can add or remove any set of these rows. I need to do this in jQuery.
Does anyone have any good links for this sort of feature/plugin in jQuery
I have a control with 2 textboxes and a select box in one row.
Share
I’ve posted a quick and, fairly, dirty means of doing this over on jsbin, the JS and CSS is below:
JavaScript/jQuery:
CSS:
There’s the relatively large issue of how you’re generating the dynamically-added
selectboxes, but I leave that -happily- as an excercise for you, and there’s probably a far, far nicer means of generating thenewXhtmlvariable, but I chose to leave it for simplicity.The current implementation, due to the
if ($('fieldset').length > 1)assessment prevents the user from deleting all fieldsets, but doesn’t prevent them deleting a particular fieldset. You may wish to sanity-check that approach. If you have any questions, please feel free to ask in the comments and, well, I’ll do my best =)