#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    1
    Rep Power
    0

    Question check matching elements in an array javascript


    I have an Array of 6 elements in javascript,which are the selected values of drop down boxes in my asp application.

    I would like to know ,is there any way possible of checking wether any of the elements in the array match each other.
    I know i could write if statements but is it possible with looping constructs?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    1
    Rep Power
    0
    Hm. You could try the easy, but not very elegant way: Just check every element against all other elements.
    Maybe it would work this way:

    PHP Code:
    function checkMultipleEntries (someArray) {
    for (var 
    0someArray.lengthi++) {
    for (var 
    0someArray.lengthj++) {
      if (
    != && someArray[j] == someArray[i]) return false;
    }
    }
    return 
    true;


IMN logo majestic logo threadwatch logo seochat tools logo