ECMAScript Client Object Model – Update a look up field

In a previous post I discussed how to retrieve some values from a SharePoint list and bind it to a drop down list (HTML select). Later I had a requirement update back the selected value of the drop down to another separate list. The values I was retrieving was a lookup field in the second list I wanted to update.

My previous article on retrieve list data : Retrieve Data

So had to spend some time to properly understand how to do the look up field update using client object model.

I added a html button and wrote down a onclick event for the button.

<input type=”button” value=”Submit” onclick=”createListItem();” />

Below is the complete ECMAScript for the new list item update. It contains the two callback functions for successful item creation and failure of item creation. After a successful item creation, the new list item id will be displayed in a alert. Continue reading