Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19332

Re: How to I remove many items from an array

From "Tony" <tony.johansson@inport.com>
Newsgroups comp.lang.javascript
Subject Re: How to I remove many items from an array
Date 2013-04-18 12:51 +0200
Organization A noiseless patient Spider
Message-ID <kkoj2l$7dd$1@dont-email.me> (permalink)
References <kkoig1$3nq$1@dont-email.me>

Show all headers | View raw


I found the solution

  var i = remArray.length;
            while (i--)
            {
                if (remArray[i] != undefined)
                {
                    hinderArray.splice(remArray[i], 1);
                }
            }


"Tony"  wrote in message news:kkoig1$3nq$1@dont-email.me...

Hello!

I have an array define like this
var hinderArray = new Array();
hinderArray[i] = { Pid: value.pid, Beskr: value.beskr, Enable: false  };


In this code snippet I set the field Enable=true if the checkbox is checked.
I want instead to remove the whole item if the checkbox is not checked.
So assume that the hinderArray contains 10 items and only the first checkbox
is checked
then the hinderArray should only contain one item with the one that was
checked.

I have tried to use  hinderArray.splice(i,1); but that is not working.
How should I accomplish this ?

function BtnConfirm_click()
{
         for (i = 0; i < hinderArray.length; i++)
         {
                if (document.getElementById('chk' + i).checked)
                {
                    hinderArray[i].Enable = true;
                }
                else
                {
                    // tried with hinderArray.splice(i,1);
                }
         }
}

//Tony 

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to I remove many items from an array "Tony" <tony.johansson@inport.com> - 2013-04-18 12:41 +0200
  Re: How to I remove many items from an array "Tony" <tony.johansson@inport.com> - 2013-04-18 12:51 +0200
    Re: How to I remove many items from an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-18 15:09 +0200
      Re: How to I remove many items from an array "Tony" <tony.johansson@inport.com> - 2013-04-18 17:49 +0200
        Re: How to I remove many items from an array "Tony" <tony.johansson@inport.com> - 2013-04-18 17:55 +0200
        Re: How to I remove many items from an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-18 18:51 +0200

csiph-web