Creating And Copy/duplicating A Select/option List Menu With JavaScript September 29, 2022 Post a Comment I have a select list menu: 1 2 Solution 1: I can't test in IE right now, but try using .cloneNode() instead to create the new element. var selectt = document.getElementById("select1").cloneNode(true); selectt.setAttribute("name", "select"+counter); selectt.setAttribute("id", "select"+counter); selectt.onchange = (function( cntr ) { return function() { sellcalculate(cntr); }; })( counter ); cell3.appendChild(selectt); Copy The true argument passed to .cloneNode makes it a deep clone (all descendants). Also, I assumed you want the onchange handler to reference the current value of counter instead of a potentially different future value. As such, I scoped the current value using a new function invocation. Now whatever the value of counter is when this code runs will be the value passed to sellcalculate(). Solution 2: You can use jQuery .clone() like this: $('#select1').clone().attr({'id':'select'+counter, 'name':'select'+counter}).appendTo('cell3Selector'); Copy Test page here. Share Post a Comment for "Creating And Copy/duplicating A Select/option List Menu With JavaScript" Top Question Input Type Datetime-local Is Not Working In Firefox I have an input type of datetime-local which is working fin… Can I Absolutely Position An Element In The Top Right Corner Of A Element? I have a table and I need the cells to have an element posi… CSS - Auto Fill Height Here's a js fiddle of what I currently have, I am tryin… Store A Generated Random Number In A Variable, Then Call That Variable As A Filename To Bring Up An Image. Javascript So I have a few pictures that I want to randomly generate o… CSS Hover Jitter Issue This is my first question. I usually try to research these … Right Floated Element Disappears When Using Columns In Firefox I am using an ol element with column-count and column-gap p… Setting Link Href From Child Image Src Using JQuery I am using .wrap() to create a link around each image withi… How To Limit The Html Table Records In Each Page I am populating a table in my jsp which has more than 20 re… Separate Countdown For Divs I want to show countdown in each of my divs. Right now I ge… Retain Dynamically Created DropDown List's Selected Value On Event Window.history.back()- JavaScript Can use the below question as a reference to explain the co… December 2024 (1) November 2024 (38) October 2024 (60) September 2024 (20) August 2024 (360) July 2024 (336) June 2024 (693) May 2024 (1285) April 2024 (802) March 2024 (1568) February 2024 (1697) January 2024 (1377) December 2023 (1447) November 2023 (380) October 2023 (599) September 2023 (335) August 2023 (347) July 2023 (287) June 2023 (341) May 2023 (234) April 2023 (140) March 2023 (130) February 2023 (178) January 2023 (281) December 2022 (110) November 2022 (237) October 2022 (815) September 2022 (159) August 2022 (296) July 2022 (96) Menu Halaman Statis Beranda © 2022 - Html5 World