Javascript: removing element from object
Results 1 to 4 of 4

Thread: Javascript: removing element from object

  1. #1
    Senior Member codenamevirus's Avatar
    Join Date
    Jun 2005
    Location
    Faridabad, Haryana, India
    Posts
    298

    Exclamation Javascript: removing element from object

    Hi

    I have an object in Javascript of a structure like:

    objID{ name, arr[], int}

    now the arr[] is of the length = 7.

    so, its like objID.arr[0] to objID.arr[6].

    Now, I have a requirement of removing an element from this array according to the scenario.

    Say Idx is the array element to be deleted

    So, I tried objID.arr.splice(Idx, 1);
    to which I got the exception:
    "Microsoft JScript runtime error: Object doesn't support this property or method"

    And then I tried delete objID.arr[Idx];
    to which I got the exception:
    "Microsoft JScript runtime error: Object doesn't support this action"


    so, what can be done to remove the element from the object and then adjust the arrays.

    Like, if in the starting I have array of 4 elements like:
    objID.arr[0] = a
    objID.arr[1] = b
    objID.arr[2] = c
    objID.arr[3] = d

    and I remove the element at index 2! the new array should be like:
    objID.arr[0] = a
    objID.arr[1] = b
    objID.arr[2] = d


    Thanks in advance!
    CodeNameVirus

  2. #2

  3. #3
    Senior Member codenamevirus's Avatar
    Join Date
    Jun 2005
    Location
    Faridabad, Haryana, India
    Posts
    298
    that was a lot of help! thanks!
    CodeNameVirus

  4. #4
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,053
    No problem!

Similar Threads

  1. Windows Error Messages
    By cheyenne1212 in forum Miscellaneous Security Discussions
    Replies: 7
    Last Post: February 1st, 2012, 02:51 PM
  2. Should I be worried....?
    By jerichoholic in forum Spyware / Adware
    Replies: 12
    Last Post: November 30th, 2004, 11:14 AM
  3. HJTlog and the ISP ads
    By coolcamel in forum Spyware / Adware
    Replies: 8
    Last Post: September 29th, 2004, 03:54 PM
  4. JavaScript - Three Chapters
    By jethro in forum Other Tutorials Forum
    Replies: 5
    Last Post: November 3rd, 2002, 03:09 PM
  5. Difference between Java and JavaScript
    By Remote_Access_ in forum Security Archives
    Replies: 4
    Last Post: January 3rd, 2002, 11:11 PM

Posting Permissions

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