1 Reply Latest reply: Oct 17, 2013 6:40 AM by anai RSS

    JavaScript equivalent of SQL in


      Hi all,


      I do not know where to ask this question, but I am trying to write a javasctript for my dynamic action.


      Now I have to check a variable for values and I do it like this:


      if ($v("APEX_ITEM") == 1 && $v("APEX_ITEM")==2) { ....}


      In SQL I would write:


      apex_item in (1,2)


      Is there something like that for Javascript because I have a list of ten id's.


      Thank you.


        • 1. Re: JavaScript equivalent of SQL in

          You could use indexOf, but that doesn't work in IE.


          Try this:


          var list = [ "1", "2", "3", "4"];
          alert(jQuery.inArray( "3", list ));  //this will return 2
          alert(jQuery.inArray( "5", list )); //this will return -1


          If the element is not in list, inArray will return -1. So basically, you need to check if the returned value is -1 (the element is not in list) or greater (the element is in list).