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

  • SEARCH
  • Home
  • 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 1113731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:03+00:00 2026-05-17T02:54:03+00:00

I am building a dynamic form in that the user can keep adding entries

  • 0

I am building a dynamic form in that the user can keep adding entries until they satisfied, to do this, I use this javascript, to pull in some html,

$('#add_another').click(function(e){
    $.get('/admin/add_grade_course', function(data) {
        $('#added_by_ajax').append(data);
    });
    e.preventDefault();
});

The HTML that is returned is a follows,

<fieldset>
    <select name="course_type">
        <option value="Classroom based learning">Classroom Based Learning</option>
        <option value="Apprenticeship based learning">Aprenticeship Based Learning</option>
        <option value="On the Job Learning">On The Job Learning</option>
    </select>
    <label for="course_names">Course Name</label>
    <input type="text" name="course_names" value="<?php set_value('course_names');?>"/>
    <?php echo form_error('course_names'); ?>

    <label for="course_links">Course Links</label>
    <input type="text" name="course_links" value="<?php set_value('course_links');?>"/>
    <?php echo form_error('course_links'); ?>

    <label for="grade_desc">Description of Grades Needed</label>
    <textarea name="grade_desc"><?php set_value('grade_desc')?></textarea>

    <a href="#" class="remove_fields">Delete</a>


</fieldset>

My question is that as you can see there is nothing unique about the entry form that is created on the fly, if the user has added a new entry field and then decides they dont need it, how would I go about removing the last added form elements?, I assume I need to somehow get the parent fieldset for the clicked .remove_fields link? How would I do that, without selecting all the fieldsets on the page?

  • 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-17T02:54:04+00:00Added an answer on May 17, 2026 at 2:54 am

    The following will bind to the click event using the live() function and remove the selected entry. The live function is handy because it means that any dynamically added markup that matches the selector will have the function bound as it is added. This means that each time the user clicks the add_another link, the newly returned fieldset has the function bound to the click event of its remove_fields link.

    $(function(){ //shorthand for $(document).ready(function(){
        $('.remove_fields').live('click', function() {
           //$(this).parent() returns the current fieldset, remove() removes it. 
           $(this).parent().remove();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building a dynamic form that allows the user to add as
I am building a dynamic form creator that allows users to add form elements
So, I'm building a form that my users can customize based on their needs,
I am building a dynamic form system that will automatically assemble an HTML form
I'm building an employment application form that's dynamic. I want a field that asks
I am building a dynamic form in a Cocoa application and am planning to
I am building a website that would serve dynamic content. All communication between server/browser
I hope someone can help me..... i am trying to build a dynamic form
I'm building a dynamic drop down box for an HTML form using PHP and
I'm building an ASP.NET MVC application with a form that needs validation. The majority

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.