GetListItems and Update List Items

Apr 14, 2014 at 7:31 PM
Edited Apr 14, 2014 at 7:59 PM
I know I was looking for a long time on how to get data from one list to another so I thought I might post what ended up working for me. I used two functions one to grab all of the data and the other to create new items in the second list. I know this probably is not the best way I could have accomplished my task since I am pretty new to JavaScript, but it works for my purpose and I hope it can help someone else.
<script src="//"></script> 

<script language="javascript" type="text/javascript" src="/SiteCollectionDocuments/jquery.SPServices-2014.01.min.js"></script>

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

function Main() {
    operation: "GetListItems",
    async: false,
    listName: "Shelter Status",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {

function CreateNewItem(ShelterName, TypeofShelter, ShelterAddress, ShelterCity, ShelterZipCode, TotalShelterCapacity ) {
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "TestShelterStatus",
        valuepairs: [["Title", ShelterName],["Type_x0020_of_x0020_Shelter", TypeofShelter],["Street_x0020_Address",ShelterAddress],["City",ShelterCity],["Zip_x0020_Code",ShelterZipCode],["Total_x0020_Shelter_x0020_Capaci",TotalShelterCapacity],["Citizens","0"]],
        completefunc: function(xData, Status) {
       //   alert(TypeofShelter);

<input id="Button" type="button" value="Click To Copy to Event" onclick="Main();" />
<p> After clicking button, Please wait for the Complete Message</p>
Apr 16, 2014 at 5:41 PM
Hey, if it works, it works! It seems about right to me.