Sharepoint - Multiple Values in CAML query from Array? SharePoint 2010 using jQuery/SPServices

It is more a caml question than an SPServices question.

Often one uses or and and operators to combine multiple values, which, like @rjcp3 said, can be messy.

There is another operator, less known, IN operator to choose a range of values (see the xml example below).

To simplify the creation of CAML queries in javascript, I'd recommend SharePoint EcmaScript Caml Builder - an open source javascript library released under the Ms-PL licence on codeplex. Creds go to omlin.

Here is an example from camljs.codeplex.com:

caml = camlBuilder.Where()
    .LookupIdField("Category").In([2, 3, 10])
    .And()
    .DateField("ExpirationDate").LessThanOrEqualTo("{Now}")
    .OrderByDesc("ExpirationDate")
    .ToString()

This results in the following CAML query which you can put into a SPServices request:

<Where>
  <And>
    <In>
      <FieldRef Name="Category" LookupId="True" />
      <Values>
        <Value Type="Integer">2</Value>
        <Value Type="Integer">3</Value>
        <Value Type="Integer">10</Value>
      </Values>
    </In>
    <Leq>
      <FieldRef Name="ExpirationDate" />
      <Value Type="Date">
        <Now />
      </Value>
    </Leq>
  </And>
</Where><OrderBy>
  <FieldRef Name="ExpirationDate" Ascending="False" />
</OrderBy>