Delete Array

Results 1 to 2 of 2

Thread: Delete Array

  1. #1
    Join Date
    Dec 1969

    Default Delete Array

    Hi<BR><BR>How do I delete an entry from an array? I have a multi-dimensional array called cartArray. The array is held in a global session variable so that I can use it in different pages. It is basically a checkout script that has a delete button next to it that calls a delete page. Heres my attempt so far for the delete page:<BR><BR>thei = request.querystring("arrayid") &#039;get the array id<BR><BR>cartArray = Session("cartArray") &#039; call the array<BR><BR>redim preserve cartArray(thei - 1) &#039; don’t know what I am doing here :-)<BR><BR>Any ideas<BR><BR>Thanks<BR><BR>Gary<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Delete Array

    You&#039;d need to be in javascript or jscript to make this easy.<BR>(push, pop, shift, unshift and splice methods)<BR><BR>If you seek to remove the last element of the array, its pretty easy<BR><BR>Redim preserve myArray(UBound(myArray)-1)<BR><BR>For all other possibilities, they demand some more care.<BR><BR>Personally, I&#039;d just say :<BR><BR><BR>Dim myString<BR><BR>cartArray(thei) = "" &#039;empty it<BR>myString = Join(myArray, "&") &#039;Make a string with "&" as the separator<BR>myString = Replace(myString, "&&", "&") &#039;Replace && by & (thus killing the empty elements<BR>myArray = Split(myString, "&") &#039;Recreate the array<BR><BR>Maybe the others will have a better suggestion though :)<BR><BR>Eniac

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts