www.webdeveloper.com
Results 1 to 3 of 3

Thread: JavaScript Arrays

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    3

    resolved JavaScript Arrays

    function chkcount(cid)
    {
    var car=new Array();
    var chkStatus=document.getElementById(cid).checked;
    if(chkStatus == true)
    {
    //car.push(cid);
    alert(chkStatus);
    }
    else
    {
    if (car.lastIndexOf(cid)!=-1)
    {
    car.splice(car.lastIndexOf(cid), 1);
    alert(' ' + car.lastIndexOf(cid));
    }
    }
    alert(' ' + car);
    }

    What is the error in this function block.....
    I am getting an error in else block at lastIndexOf().....
    The cid value will be like chk1, chk2, chk3....

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    The lastIndexOf() method returns the position of the last found occurrence of a specified value in a string. (www.w3school.com)

  3. #3
    Join Date
    Sep 2009
    Posts
    159
    It looks like the closing brace in the last line doesn't have matching opening brace. Check your brace pairs again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles