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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:12:27+00:00 2026-06-13T12:12:27+00:00

I want to reset new values each time in the option list created JSON

  • 0

I want to reset new values each time in the option list created JSON by the line:

var o=document.createElement("option");
document.getElementById("shipTo").options.add(o); 
o.text= address[i];

But new option values are added in the list I want the no previous in the option:

var counter;
function GetAddress() {
    var customerId = document.getElementById("invoiceTo").value;
    var xml;
    if (window.XMLHttpRequest) {
        xml = new XMLHttpRequest();
    } else {
        xml = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xml.onreadystatechange = function() {
        if (xml.readyState == 4 && xml.status == 200) {
            var address = JSON.parse(xml.responseText);
            document.getElementById("billingAddress").value = address[0];
            document.getElementById("shipAddress").value = address[0];
            if (counter == 1) { {
                    for (var i = 0; i < address.length; i++) {
                        var removeMe = document.getElementById(o[i]);
                        removeMe.parentNode.removeChild(removeMe);
                        var o = document.createElement("option");
                        document.getElementById("shipTo").options.add(o);
                        o.text = address[i];
                    }
                }
            } else if (counter != 1) {
                for (var i = 0; i < address.length; i++) {
                    var o = document.createElement("option");
                    document.getElementById("shipTo").options.add(o);
                    o.text = address[i];
                }
            }
            counter = 1;
        }
        alert(counter);
    }
    xml.open("GET", "GenerateInvoice?customerId=" + customerId, true);
    xml.send();
}
  • 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-13T12:12:28+00:00Added an answer on June 13, 2026 at 12:12 pm

    You need to clear the options first:

    var oDDL = document.getElementById("shipTo");
    while (oDDL.options.length > 0)
        oDDL.options.remove(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to reset a file upload field when the user selects another option.
i am fetching data using following code _.each(cardIds, function(id){ var mdc = new MdlCard({cardId:
I want to reset an object. Can I do it in the following way?
I have multiple input textboxes in my page. I want to reset particular text
I want my application to reset shared preferences when the application reinstalling let's say
I am implementing a password reset function and would have the key I want
How do I reset my numbers after they count? I want something like an
I want keep track of a unique identifier for each browser that connects to
In drupal i have generated a list where each item is a fieldset with
Updated with actual JSON Response, Messed up last time. It is my second day

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.