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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:35:24+00:00 2026-06-05T18:35:24+00:00

I figured out how to clone my form rows and append an incriminting number

  • 0

I figured out how to clone my form rows and append an incriminting number to the end of the ID’s for each form field. So I thought with that appended incriminenting number at the end of the ID it would then be easy to use on change event to copy the value of one id to another, but this is not working for the cloned rows!

I am using this to create new form rows:

$('#btnRemove').attr('disabled','disabled');
            $('#btnAdd').click(function() {
                var num     = $('.clonedInput').length;
                var newNum  = new Number(num + 1);

                var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);

                                newElem.children('.product').attr('id', 'product' + newNum).attr('name', 'product' + newNum);
                newElem.children('.productid').attr('id', 'productid' + newNum).attr('name', 'productid' + newNum);

                $('#input' + num).after(newElem);
                $('#btnRemove').removeAttr('disabled','disabled');

                if (newNum == 7)
                $('#btnAdd').attr('disabled','disabled');


            });

            $('#btnRemove').on('click', function() {
                $('.clonedInput').last().remove();
                $('#btnAdd').removeAttr('disabled','disabled');
            });

And I am (trying) to use this code to copy the serialized product id .val(value.split('-')[3]) from the product select value to the ‘id’ field in the form. It only works for the first one though, and does not work on the ‘cloned’ form fields:

 $("#product").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid").val(value.split('-')[3]);
        }).keyup();
        $("#product2").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid2").val(value.split('-')[3]);
        }).keyup();
        $("#product3").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid3").val(value.split('-')[3]);
        }).keyup();
        $("#product4").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid4").val(value.split('-')[3]);
        }).keyup();
        $("#product5").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid5").val(value.split('-')[3]);
        }).keyup();
        $("#product6").on('change keyup', function() {
        var value = $('option:selected', this).val();
            $("#productid6").val(value.split('-')[3]);
        }).keyup();​

I put this on jsfiddle so it will be easier to see what my problem is: Demo

  • 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-05T18:35:26+00:00Added an answer on June 5, 2026 at 6:35 pm

    As you’re creating select using clone and append to DOM dynamically, so you need delegate event handler for them

    // delegate event handler
    $('#myForm').on('change keyup', 'select[id^=product]', function() {
        var value = $('option:selected', this).val();
        $(this).next('input.productid').val(value.split('-')[3]);
    }).keyup();
    

    DEMO

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

Sidebar

Related Questions

I figured out that CUDA does not work in 64bit mode on my mac
I figured out that of course . and SPACE aren't allowed. Are there other
I haven't figured out the correct programming architecture for: -WPF Application -Each build will
This week I have figured out how to modify form elements in the location
I've figured out that default ReceiveBufferSize (8192) doesn't work for me - I lose
I did some all day learning and I figured out how to add rows
I have a function called taskButtonClick() that: Sets the variable form to a clone.
I'm pretty close to having this figured out and just need the last bit
I figured out how to get all the user's images in the camera roll
I figured out how to pass a String value between activites thanks to this

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.