2012-08-30 46 views
0

我只是進入Sharepoint的SPServices,似乎它可能是我的需要的業務,即編程方式更新列表中的值。尋找一個非常簡單的示例UpdateListItems的SP服務與SharePoint 2007

作爲一個測試,我嘗試了下面的代碼來更新名爲jQueryList的列標題列,其中有一行(ID = 1)。

<script src="..../js/jquery.SPServices-0.7.1a.min.js" type="text/javascript"></script> 
<script src="..../js/jquery-1.7.1.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
$(document).ready(function() { 
$(#inhere).html(waitMessage).SPServices({ 
    operation: "UpdateListItems", 
    listName: jQueryList, 
    ID: 1, 
    valuepairs: [["Title", "eggs"]], 
    completefunc: function (xData, Status) { 
     var out = $().SPServices.SPDebugXMLHttpResult({ 
      node: xData.responseXML, 
      outputId: inhere 
     }); 
     $(#inhere).html("").append("<b>This is the output from the UpdateListItems operation:</b>" + out); 
     $(#inhere).append("<b>Refresh to see the change in the list above.</b>"); 
    } 
}); 
} 
</script> 
<div id="inhere"> 
</div> 

我已經把CEWP放在我的列表jQueryList的底部,但它並沒有更新我行的值。 關於這個問題的全新手風格道歉,但如果任何人有任何指針,我會很感激。 注意:我在默認視圖中顯示ID列的ID值。

最好的問候/科爾姆

+0

嗯,listName應該用引號括起來,即「jQueryList」 – carbontracking

回答

1

下面會發生什麼都按相同的子網站列表上罰款,我要挖多一點,看看如何爲一個單獨的子網站的列表做到這一點。

<script src="http://ccs.xxx.corp/sites/TDP_SCS/SiteAssets/js/jquery-1.8.2.js" type="text/javascript"></script> 
<script src="http://ccs.xxx.corp/sites/TDP_SCS/SiteAssets/js/jquery.SPServices-0.7.2.js" type="text/javascript"></script> 
<script language="javascript" type="text/javascript"> 
$(document).ready(function() { 
$().SPServices({ 
    operation: "UpdateListItems", 
    async: false, 
    batchCmd: "Update", 
    listName: "jQueryList", 
    ID: 1, 
    valuepairs: [["Title", "eggs & ham"]], 
    completefunc: function (xData, Status) { 
     alert("Dang"); 
    } 
}); 
}); 
</script> 
相關問題