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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:21:51+00:00 2026-05-21T05:21:51+00:00

I have some items I am storing in an element that get added at

  • 0

I have some items I am storing in an element that get added at various times like this:

document.getElementById('rout_markers').value = str;

I am not too good with JavaScript, but as I understand it, the values get stored as an array, correct?

What I need to do is to be able to remove all the elements or to be able to remove the last element that was added.

How can I do that?
Thanks!

  • 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-05-21T05:21:52+00:00Added an answer on May 21, 2026 at 5:21 am

    If you’re assigning str to an element then there are no arrays involved here – you’ll be overwriting each previously-assigned value with the latest and thereby storing only the latest value.

    You could use an array but you’d have to know the location of each item in the array, so if you wanted to assign or nullify a specific element in your array, you’d have to a have a record of where it was – although you could get around that it with a multi-dimensioned array, where the first element at each index is the name of the property, and the second element at each index is that value of the property.

    If you want to store multiple properties in a field in order to retrieve them all later, there are two simple ways of doing this.

    1. Consider using either a field for every property.
      If you do this then I’d suggest using a naming convention for the fields so that you can more easily assign the property.

    2. Concatenating a string to form a collection of key-value pairs, very much like a query-string.
      In the example you gave, this would mean storing something like:

    var keyVals = 'route_markers' + '=' + str + '&';
    document.getElementById('myHiddenProperties').value = keyVals;

    When you want to assign another property to this string you do something like this:

    keyVals = document.getElementById('myHiddenProperties').value;
    keyVals += 'new_property' + '=' + myNewValue + '&';
    document.getElementById('myHiddenProperties').value = keyVals;
    

    In this way, if you want to remove a specific key-value pair, you split the stored value like this

    var arrKeyVals = document.getElementById('myHiddenProperties').value.split('&');
    

    You then have an array of key-value pairs.

    If you want to retrieve a value from this array, or blank one of the values then loop through this array, splitting each into its key and value, like this:

    for (var i = 0; i < arrKeyVals.length; i++) {
        var keyVal = arrKeyVals[i].split('=');
        var key = keyVal[0];
        var val = keyVal[1];
        if (key == name_of_key_sought) {
            val = ''; //assign an empty string to this property to forget about it
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have a JSP page that allows to sort some items, when
Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
In some library code, I have a List that can contain 50,000 items or
I have a ListBox displaying some items, and in certain modes I stamp a
I have a table with say 1640 items. I set bindingSource.Filter = some filter
I have some business objects which use: Web.Configuration.WebConfigurationManager.AppSettings.Item(SomeSetting) Now that I'm breaking those objects
I have some UI in VB 2005 that looks great in XP Style, but
We have some input data that sometimes appears with &nbsp characters on the end.
I am creating a JSF application. I have some items (e.g. products) from database
I have been working on this problem for quite some time and can't figure

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.