0

The code below is not working, it should find duplicate values using jQuery:

$().SPServices({
    operation: "GetListItems",
    listName: "Questions",
    async: false,
    CAMLQery: query,
    completefunc: function(xData,status)
        {
            $(xDataresponseXML).find("\\z:row").each(function()
                {
                    var duid-$(this).attr("ID");
                        if(i==duid)
                            {
                                alert("Found");
                            }

                 });   
         }

});  
1

A small example to get the items, show them, find duplicates and show the unique ones:

<script type="text/javascript">

  $(document).ready(function () {

  var items = {};

  $().SPServices({
  operation: "GetListItems",
  async: false,
  listName: "Cities",
  CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
  completefunc: function (xData, Status) {
  $(xData.responseXML).find("[nodeName='z:row']").each(function () {
  var title = $(this).attr("ows_Title");
  $("#results").append(title);

  if(items[title])
  $this.remove();
  else
  items[title]=true;

  });
  }
  });


  $.each(items,
  function (value) {
  $("#noduplicates").append(value);
  });


  });

</script>
<div id="results">
</div>

<br />
<br />
<br />

<div id="noduplicates"></div>

I used a simple custom list named 'Cities' and added no extra columns, just used the Title field. When entering a duplicates value into the Title column, this item will show in the div 'results', but not in the div 'noduplicates'. I think this example will help you build your solution.

  • Hi Anita,Thanks for your response.But i am not able to get the list items and below is the code will you view and respond to me.And the end i used alert message to get the list item value which i am not able to get var i=$(this).attr('A'); alert(i);.I am able to connect to list but not able to get the list item value .Would please tell me is the above code write to get list item value or not. – MSA Oct 22 '11 at 7:13
  • Ow, you're not getting the items at all? That's a different question. I'll update my answer with some more info which may help you. – Anita Boerboom Oct 24 '11 at 7:05
0

What are you trying to accomplish?

Just by looking I have the following remarks:

  • There is a - after var duid, shouldn't that be an =?
  • What value has i? Where is it set?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.