Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: Single List Item

So, finally got it to work! Need a few more customizations to the pop up in the map, however thanks for the help guys, what a great way to end a Friday! SPServices made my weekend again, also Tiger shooting a 61 today was nice as well.......
// JS file that powers the IT Asset Maps pages

$(document).ready(function() {
    
    var qsVals = $().SPServices.SPGetQueryString();
    var qsID = qsVals["ID"];
        
    // pass qsID into the CAMLquery below
    var location = '';
    $().SPServices({
        operation: 'GetListItems',
        async: false,
        //debug: true,
        listName: 'IT Assets',
        CAMLViewFields: '<ViewFields><FieldRef Name="Location" /></ViewFields>',
        CAMLQuery: '<Query><Where><Eq><FieldRef Name="ID"/><Value Type="Counter">' + qsID + '</Value></Eq></Where></Query>',
        completefunc: function(xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                //alert($(this).attr("ows_Location").slice(3));
                var location = $(this).attr("ows_Location").slice(3);
                //alert(location);
                getLocation(location);
            });
        }
    });
    function getLocation(loc) {
        $().SPServices({
            operation: 'GetListItems',
            async: false,
            debug: true,
            listName: 'Location',
            //webURL: 'http://dfhsp.com/sites/DFH/ISDept/support/Lists/Location/',
            CAMLViewFields: '<ViewFields><FieldRef Name="Address" /><FieldRef Name="City" /><FieldRef Name="State" /></ViewFields>',
            CAMLQuery: '<Query><Where><Eq><FieldRef Name="Title"/><Value Type="Text">' + loc + '</Value></Eq></Where></Query>',
            completefunc: function(xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    var address = $(this).attr("ows_Address");
                    var city = $(this).attr("ows_City");
                    var state = $(this).attr("ows_State").slice(4);
                    //alert($(this).attr("ows_ID"));
                    var fullAdd = address + ',' + city + ',' + state;
                    $('.ms-formtable').after('<div id="assetMap"></div>');
    
                    $('#assetMap').goMap({
                        address: fullAdd, 
                        zoom : 15
                        
                    });
                    $.goMap.createMarker({
                        address: fullAdd,
                                title : loc,
                                html : {
                                    content : loc,
                                    popup : true
                                }
                    });             
                });
            }
            
        });
        
        
    }
});



Viewing all articles
Browse latest Browse all 6517

Trending Articles



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