Monday, October 19, 2015

How to get with the same titles get number of List Items Count using SPServices

Script:
<script language="javascript" type="text/javascript">

  $(function() {

getcount();
});
function getcount()
{  
    var dataCount=0;
    var queryText = "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>Apple</Value></Eq></Where></Query>";
 
    $().SPServices({

        operation: "GetListItems",
        listName: "Furits",
        async: false,
        CAMLQuery: queryText,
        completefunc: function (xData, status) {          
            dataCount= $(xData.responseXML.xml).find("rs\\:data, data").attr("ItemCount");        
//In dataCount  variable ,We will get list items Count
            $("#txtcount").val(dataCount);

        }
    });
           }

</script>

HTML
<input type="text" id="txtcount"/>
 <a onclick="javascript:getcount();">Click Here</a>

No comments:

Post a Comment