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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:54:34+00:00 2026-06-05T17:54:34+00:00

So basically, I’ve run into this problem enough times that it is seriously frustrating

  • 0

So basically, I’ve run into this problem enough times that it is seriously frustrating me.

What I’d like to do is have code like this:

node = document.createElement("option");
textbox = document.createTextNode(currentday.getFullYear() + i);
node.value = currentday.getFullYear() + i;
node.appendChild(textbox);
document.getElementById("pick_up_year").appendChild(node);
document.getElementById("return_year").appendChild(node);

But this code only appends the nodes to return_year (a select element, obviously).

It DOES work if I repeat the code like this:

node = document.createElement("option");
textbox = document.createTextNode(currentday.getFullYear() + i);
node.value = currentday.getFullYear() + i;
node.appendChild(textbox);
document.getElementById("pick_up_year").appendChild(node);
node = document.createElement("option");
textbox = document.createTextNode(currentday.getFullYear() + i);
node.value = currentday.getFullYear() + i;
node.appendChild(textbox);
document.getElementById("return_year").appendChild(node);

But that’s hardly elegant, is it? Why am I forced to reuse code and is there an easy way around this?

The HTML is basically this:

<select id="pick_up_days" name="pick_up_day">
    <option value="nojs">Please enable JavaScript</option>
</select>
<select id="pick_up_year" name="pick_up_year">
    <option value="nojs">Please enable JavaScript</option>
</select>
  • 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-05T17:54:36+00:00Added an answer on June 5, 2026 at 5:54 pm

    You can try with cloneNode

    document.getElementById("pick_up_year").appendChild(node);
    document.getElementById("return_year").appendChild(node.cloneNode(true));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a few functions that look like this: class MyClass { void
Basically I have some simple code that does some things for files and I'm
Basically from a database I am getting data that is formatted like this nameofproject101
Basically, I'd like to know if this code is okay, <body id=some_id <!--[if lt
Basically i have a problem with this timer program I am trying to put
Basically I have an iframe loaded that is accessed from the parent whenever it
Basically I have converted a tab delimited txt file into a list containing a
Basically, I have a main page (parent page) with a link that opens up
Basically this function is meant to store the height value of the element that
basically I have a function that resizes elements accordingly with jquery triggering the function

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.