Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:08:28+00:00 2026-05-17T01:08:28+00:00

I have a control with 2 textboxes and a select box in one row.

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:08:29+00:00Added an answer on May 17, 2026 at 1:08 am

    I’ve posted a quick and, fairly, dirty means of doing this over on jsbin, the JS and CSS is below:

    JavaScript/jQuery:

    $(document).ready(
        function() {
            $('span.add').live('click',
                function() {
                    var
                    lastRow = parseInt($('fieldset:last-child').attr('id').slice('1')),
                    newRow = lastRow+1,
                    newXhtml = '<label for="inputRow' + newRow + '">Label Text</label> <input type="text" name="inputRow' + newRow + '" id="inputRow' + newRow + '" <label for="selectRow' + newRow + '">Label Text</label> <select name="selectRow'+newRow+' id="selectRow'+newRow+'><optgroup label="something"><option value="thisVal">This Value</option><option value="thatVal">That Value</option></optgroup></select><span class="addDelete"><span class="delete">X</span><span class="add">+</span></span>';
                    $('form').append('<fieldset id="_' + newRow + '" />');
                    $('form fieldset:last-child').prepend(newXhtml);
                }
            );
            $('span.delete').live('click',
                function() {
                    if ($('fieldset').length > 1) {
                        $(this).closest('fieldset').remove();
                    }
                }
            );
        }
    );
    

    CSS:

    fieldset    {
            width: 40em;
            margin: 1em auto;
            font-size: 0.8em;
            }
    
    fieldset input,
    fieldset label  {
            display: inline;
            width: auto;
            }
    
    span.addDelete  {
            float: right;
            }
    
    span.addDelete span {
            border: 1px solid #000;
            color: #000;
            font-weight: bold;
            margin: 0 0.2em 0 0;
            }
    
    span.delete     {
            background-color: #f00;
            }
    
    span.add    {
            background-color: #0f0;
            }
    

    There’s the relatively large issue of how you’re generating the dynamically-added select boxes, but I leave that -happily- as an excercise for you, and there’s probably a far, far nicer means of generating the newXhtml variable, 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 =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF user control with a number of textboxes, this is hosted
I have the following set of controls. Scenario 1: If you select one of
I have a combobox on a web form. The user can select a single
I have a ASP text box control. When the user focuses on text box,
i have 10 textboxes and i need to select text from each one of
I have 4 jQuery autocomplete textboxes. I need to add some style to one
-moz-user-select Controls the appearance (only) of selection. This does not have any affect on
I have a user control in my wp7 application which contains two text boxes
I have several textboxes in my aspx file (not nested in any other controls),
I have a textbox user control and when I double click, it adds the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.