www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript Loop through list

  1. #1
    Join Date
    Jan 2005
    Location
    UK
    Posts
    381

    Javascript Loop through list

    Hi,

    I could do this in coldfusion, but I need it to be client side so I guess Javascript is the way forward.

    What I need to do is compare one list against the other, and if a value appears in both lists, show or hide a div.

    I can get the loop working but I'm not sure how to loop though each value which is seperated by a comma.

    Thanks in advance.

  2. #2
    Join Date
    Dec 2005
    Location
    Washington, DC
    Posts
    228
    if the values are separated by a comma you can use the following code snippet to generate a list of all the values.
    Code:
    var valueArray = split(commaSeparatedValueList,",");
    for(var i=0; i<valueArray.length; i++){
      //do something by accessing valueArray[i];
    }

  3. #3
    Join Date
    Jan 2005
    Location
    UK
    Posts
    381
    Thankyou, that works great, do you know how I can check to see if a list contains a certain value?

Thread Information

Users Browsing this Thread

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

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