I'm having trouble adding the information I've entered on my Custom New Form to a custom list. I'm using SPServices UpdateListItems. My challenge is to create a save button from scratch and add all the details. But I seem to be missing something as it is not adding it up.
Below is my code.
function AddListItem() { var empName = $("input[Title='Employee Name Required Field']").val(); var empJob = $("input[Title='Job Title']").val(); var empNum = $("input[Title='Employee Number']").val(); var empPN = $("input[Title='Phone Extension']").val(); var empEmail = $("input[Title='Email Address']").val(); var empAdd = $("input[Title='Address']").val(); var empCity = $("input[Title='City']").val(); var empState = $("input[Title='State']").val(); var empZip = $("input[Title='Zip Code']").val(); $().SPServices({ operation: "UpdateListItems", async: false, batchCmd: "New", listName: "Employee Directory", valuepairs:[["Title",empName],["Job Title",empJob],["Employee Number",empNum],["Phone Extension",empPN],["Email Address",empEmail],["Address",empAdd],["City",empCity],["State",empState],["Zip Code",empZip]], completefunc: function(xData, status) { alert("Saved Successfully!"); } }); I've also tried to use array for the valuepairs. This is what I've come with.
$("#btnAdd").click(function() { var myValuePairs = []; var fldItem1 = $("input[Title='Employee Name Required Field']").val(); var fldItem2 = $("input[Title='Job Title']").val(); var fldItem3 = $("input[Title='Employee Number']").val(); var fldItem4 = $("input[Title='Phone Extension']").val(); var fldItem5 = $("input[Title='Email Address']").val(); var fldItem6 = $("input[Title='Address']").val(); var fldItem7 = $("input[Title='City']").val(); var fldItem8 = $("input[Title='State']").val(); var fldItem9 = $("input[Title='Zip Code']").val(); myValuePairs.push(["Title", fldItem1]); myValuePairs.push(["Job Title", fldItem2]); myValuePairs.push(["Employee Number", fldItem3]); myValuePairs.push(["Phone Extension", fldItem4]); myValuePairs.push(["Email Address", fldItem5]); myValuePairs.push(["Address", fldItem6]); myValuePairs.push(["City", fldItem7]); myValuePairs.push(["State", fldItem8]); myValuePairs.push(["Zip Code", fldItem9]); $().SPServices({ operation: "UpdateListItems", async: false, batchCmd: "New", listName: "Employee Directory", valuepairs: myValuePairs, completefunc: function (xData, Status) { alert("Saved Successfully!"); } }); }); Hoping you guys could enlighten me with this. Thank you.