Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Reload GetListItems on Form Change

$
0
0
HI All, i am trying to reload/replace my '#Querycontent' Divide when an field on my form changes. So that if i user changes either the 'Document Type' or the 'Discipline' Select fields the GetListItems will automatically reload to Query the field changes.

My problem is that using the append command, whenever i change a dropdown fields the #QueryContent divide just keeps appending to the same divide.
$("#Querycontent").append(liHtml);
I have tried using '.html' instead of '.append' but when i do this only 1 record from the query shows.

Any ideas?
$('form :input').change(function() {
        var DocumentType = $("option:selected", $("select[title='Document Type']")).text();
        var Discipline = $("option:selected", $("select[title='Discipline']")).text();
        var SeqNo = $("input[title='Sequence No']").val();
        var PAWONo = $("input[title='PO / WO Number']").val();
    
        $("input[title='Document No']").val("MP0041" + '-' + PAWONo + '-' + Discipline + '-' + DocumentType + '-' + SeqNo);
        
        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "Vendor Register",
            CAMLViewFields: "<ViewFields><FieldRef Name='DocumentNo' /><FieldRef Name='View_x0020_Item' /></ViewFields>",
            CAMLRowLimit: 5,
            CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='Discipline'/><Value Type='Text'>" + Discipline + "</Value></Eq><Eq><FieldRef Name='DocumentType'/><Value Type='Text'>" + DocumentType + "</Value></Eq></And></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query>",
            completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
            var DocNo = ($(this).attr("ows_DocumentNo"));
            var href = ($(this).attr("ows_View_x0020_Item")).split(",")[0];
            var liHtml = "<li><a href='"+ href +"' target='_blank'>" + DocNo + "</a></li>"; 
            $("#Querycontent").append(liHtml);
            });
            }
        });
    });

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>