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 9163603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:29:06+00:00 2026-06-17T14:29:06+00:00

The background is not so necessary to understand the issue, but a basic idea

  • 0

The background is not so necessary to understand the issue, but a basic idea of what I’m trying to do: I have a form with various sections that can be expanded, edited, and collapsed again, and the state of the form fields are remembered each time. I want to offer the user the ability to “cancel” changes – if the user expands a section and makes changes, but then decides to revert to what the form section was previously (before he expanded it), they can click “cancel” and the fields will all revert. (This is essentially an “undo”/rollback button.) I am implementing this by using jQuery clone to clone the form section when expanding, and if the user hits “cancel”, I replace the updated form section with the original clone.

The problem is that “select” element selections by the user do not seem to be included in the clone. I have constructed a basic jsfiddle to demonstrate this – if you try to select something in either section and then clone it, it is cloned without the selection.

Is there any way to get around this limitation? Is there another method I should use rather than clone?

I assume that I can manually code a loop that will copy all the selected values of all the selects, but this is rather hacky. Any smoother way to deal with this?

  • 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-06-17T14:29:08+00:00Added an answer on June 17, 2026 at 2:29 pm

    Based on your fiddle:

    $(function(){
        $('#sec1Clone').click(function(){
            $("#sec1 select option:selected").attr("selected", true);
            $('#sec1').clone(true).attr('id', 'cloneOfSec1').appendTo(document.body);
        });
         $('#sec2Clone').click(function(){
             $("#sec2 select option:selected").attr("selected", true);
            $('#sec2').clone(true).attr('id', 'cloneOfSec2').appendTo(document.body);
        });
    });
    

    That seems to work if it’s an acceptable solution.

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

Sidebar

Related Questions

I have a python script that can run for long time in the background,
I have a simple challenge with a background not animating. I have used this
I do not have a formal background in Natural Language Processing was wondering if
I'm trying to warning the user if he types a word that is not
Background I have a snippet of javascript that sites on customer pages. When this
Background: I'm trying to write a shell script using php that will automatically checkout
Apologies for the length of this post, but I think the background is necessary
I have the following scenario: a Bitmap that is used as background and another
Does anybody can provide an answer to such issue? I`m trying to put some
Background: I'm coming from Java background so not too familiar with Javascript. We are

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.