好吧,老实说,我从来没有发现为什么这种方法只适用于编辑模式。所以我使用了 SPServices 选项:
<script type="text/javascript">
//Wrapping your script in $(document).ready(function()means
//that the calls will be made once the page is fully loaded,
// i.e., the page is "ready".
$(document).ready(function() {
updateReleaseSelected();
});
function updateReleaseSelected()
{
var relID = document.getElementById('ReleaseID').value;
// alert('RelID:' + relID );
updateItems(relID );
};
function updateItems(relID)
{
$().SPServices(
{
operation: 'UpdateListItems',
webURL: '/sites2/sppwgrqy/DashboardTest/',
listName: 'ReleaseSelected',
updates: '<Batch OnError="Continue" PreCalc="True">' +
'<Method ID="1" Cmd="Update">' +
'<Field Name="ReleaseValue">' + relID + '</Field>' +
'<Field Name="ID">2</Field>' +
'</Method>' +
'</Batch>',
completefunc: function(xData, Status)
{
//alert('successfully updated');
}
});
}
</script>