JavaScript 调用sharepoint内置webservice 更新item

  
function UpdateListItem()
{

var listName = " End User Computing List " ;
var a = new ActiveXObject( " Microsoft.XMLHTTP " );
if (a == null ) return ' error ' ;

var ID = GetQueryString( ' ID ' );
var ddlEvaluation = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff15_1_ctl00_DropDownChoice ' );

var ddl1 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff17_1_ctl00_DropDownChoice ' );
var ddl2 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff18_1_ctl00_DropDownChoice ' );
var ddl3 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff19_1_ctl00_DropDownChoice ' );
var ddl4 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff20_1_ctl00_DropDownChoice ' );
var ddl5 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff21_1_ctl00_DropDownChoice ' );
var ddl6 = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff22_1_ctl00_DropDownChoice ' );

var ddlTechType = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff16_1_ctl00_DropDownChoice ' );
var txtTechType = document.getElementById( ' ctl00_m_g_959a3f9b_4c02_4c3a_b885_dae28c14a9a8_ff23_1_ctl00_ctl00_TextField ' );


a.Open(
" POST " , " http://cntsnapp102.zone1.scb.net:2020/_vti_bin/lists.asmx " , false );
a.setRequestHeader(
" Content-Type " , " text/xml; charset=utf-8 " );
a.setRequestHeader(
" SOAPAction " , " http://schemas.microsoft.com/sharepoint/soap/UpdateListItems " );
var d = ' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> '
+ ' <soap:Body> '
+ ' <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> '
+ ' <listName> ' + listName + ' </listName> '
+ ' <updates><Batch OnError="Continue" ListVersion="1"> '
+ ' <Method ID="1" Cmd="Update"> '
+ ' <Field Name="ID"> ' + ID + ' </Field> '
+ ' <Field Name="Criticality_x0020_Evaluation"> ' + ddlEvaluation.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use"> ' + ddl1.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use2"> ' + ddl2.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use3"> ' + ddl3.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use4"> ' + ddl4.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use5"> ' + ddl5.value + ' </Field> '
+ ' <Field Name="Biz_x0020_Use6"> ' + ddl6.value + ' </Field> '
+ ' <Field Name="Tech_x0020_Type"> ' + ddlTechType.value + ' </Field> '
+ ' <Field Name="Tech_x0020_Type_x0020_Text"> ' + txtTechType.value + ' </Field> '
+ ' </Method> '
+ ' </Batch></updates> '
+ ' </UpdateListItems> '
+ ' </soap:Body> '
+ ' </soap:Envelope> ' ;
a.Send(d);

}

转自:http://www.cnblogs.com/catvi/archive/2011/05/27/2059607.html

你可能感兴趣的:(JavaScript)