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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:54:49+00:00 2026-06-15T03:54:49+00:00

hello guys i have a simple problem the has me stumped. i really dont

  • 0

hello guys i have a simple problem the has me stumped. i really dont know what do do. I have a function like so.

     function getThevalues(data) {
     for (var i = 1; i < data.d.length; i++) {

         MystartingLocation[i] = {}
         MystartingLocation[i]["locName"] = {}
         MystartingLocation[i]["locNode"] = {}

                var Opts  = document.createElement("option");
                var Opt = document.createElement("opo");
                MystartingLocation[i]["locNode"] = data.d[i].locNode;
                MystartingLocation[i]["locName"] = data.d[i].locName;
                Opts.text = data.d[i].locName;
                //Opt.text = data.d[i].locName;
                try {
                    document.getElementById("StartLocations").options.add(Opts);
                    document.getElementById("EndLocations").options.add(Opts);

                 }
       catch (e) {console.log(e);}


     }
 }

I’m trying to fill both the start location and the endlocation drop down list with the same values yet every attempt that i have try only fills one of them the endlocation one. What I’m i doing wrong? can someone please point me in the right direction.
Thanks
Miguel

  • 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-15T03:54:50+00:00Added an answer on June 15, 2026 at 3:54 am

    You can’t add the same element to both places in the document.

    You need to either create two option elements or clone the one you have.

    document.getElementById("EndLocations").options.add(Opts.cloneNode(true));
    

    Using two option elements would look like this:

     function getThevalues(data) {
         for (var i = 1; i < data.d.length; i++) {
    
             MystartingLocation[i] = {}
             MystartingLocation[i]["locName"] = {}
    
             var OptA = document.createElement("option");
             var OptB = document.createElement("option");
    
             MystartingLocation[i]["locNode"] = data.d[i].locNode;
    
             OptA.text = data.d[i].locName;
             OptB.text = data.d[i].locName;
    
             try {
                 document.getElementById("StartLocations").options.add(OptA);
                 document.getElementById("EndLocations").options.add(OptB);
             }
             catch (e) {console.log(e);} 
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello guys simple question that i seemed to be stumped on. I have something
Hello guys i have dataform in silverlight 4 project item source is: ItemsSource={Binding Data,
Hello guys, I have been trying to implement the DSUM function but failed to
Hello guys I have a problem with my application involving Lucene java library and
Hello guys i have a problem streaming PDF files with php, i'm using this
hello guys i have this function for focus : fav[jj].setOnFocusChangeListener(new View.OnFocusChangeListener() { public int
Hello guys I have a map like this http://sinanisler.com/demo/map/ and as you can see
Hello guys I have a DIV that I got passed trought a js function
Hello Guys! I have been trying to create a simple sample code for my
Hello guys i have server A where i would like to put a link

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.