Skip to content
Loading
  • Nanddeep Nachan
    0
    Are you referring to NewItem.aspx of SharePoint form?
    Or have you created an app and from there you want to save data to SP list? 
    0
  • Chanakya Jayabalan
    0
    Hi Jagdeesh,
     
    Try this code
    1. function additemstolist()   
    2.        {  
    3.   
    4.            var context = new SP.ClientContext.get_current();  
    5.            var web = context.get_web();  
    6.            var list = web.get_lists().getByTitle('NewList');  
    7.   
    8.            var listItemInfo = new SP.ListItemCreationInformation();  
    9.            var listItem = list.addItem(listItemInfo);  
    10.   
    11.            listItem.set_item('Title', 'My Test Title');  
    12.   
    13.            var companyValue = new SP.FieldLookupValue();  
    14.            companyValue.set_lookupId($("select[title='ddlselect'] option:selected").attr("id"));  
    15.            listItem.set_item('carlookup', companyValue);  
    16.   
    17.            listItem.update();  
    18.   
    19.            context.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailure));  
    20.   
    21.        }  
     
    0