I'm trying to use the example code but it does not appear to be working. I added the function to a click event. Not even the alert at the top works. Any ideas?
function postFunction() { //main function
alert("it worked");
$.fn.SPServices.SPAddMultipleListItems = function(options) { //add multiple list items function
var opt = $.extend({}, {
webURL: "", // [Optional] URL of the target Web. If not specified, the current Web is used.
listName: "{8EC40D21-B767-462C-BD20-5E27AFD583C8}", // The list to operate on.
batchCmd: "New", // The operation to perform. By default, New.
valuepairs: [["CustomerID","1"]], // Valuepairs for the update in the form [[fieldname1, fieldvalue1], [fieldname2, fieldvalue2]...]
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options);
var i;
var fieldNum;
var batch = "<Batch OnError='Continue'>";
for (i = 0; i < opt.valuepairs.length; ++;) {
batch += "<Method ID='" + i + "' Cmd='" + opt.batchCmd + "'>";
batch += "<Field Name='" + opt.valuepairs[i][0] + "'>" + opt.valuepairs[i][1] + "</Field>";
batch += "</Method>";
}
batch += "</Batch>";
$().SPServices({ //update list items
operation: "UpdateListItems",
async: false,
webURL: opt.webURL,
listName: opt.listName,
updates: batch,
completefunc: function(xData, Status) {
// If present, call completefunc when all else is done
if (opt.completefunc !== null) {
opt.completefunc();
}
}
}); //update list items
}; //add multiple list items function
} //main function
</script>