Below code is used to add list item into the SharePoint list using Javascript,
var FeedbackClientContext;
var FeedbackWebsite;
var FeedbackCurrentUser;
var FeedbackList;
function AddFeedbackValue()
{
var FeedbackNoteValue= $.trim($("#txtFeedback").val()); // txtFeedback name of the text box html field
if(FeedbackNoteValue.length > 0)
{
FeedbackClientContext = new SP.ClientContext("/");
FeedbackWebsite = FeedbackClientContext.get_web();
FeedbackList = FeedbackWebsite.get_lists().getByTitle('Feedback'); // name of the SharePoint list
var FeedbackListItemCreInfo = new SP.ListItemCreationInformation();
var FeedbackNewItem = FeedbackList.addItem(FeedbackListItemCreInfo);
FeedbackNewItem.set_item('Feedback',FeedbackNoteValue);
FeedbackNewItem.update();
FeedbackClientContext.executeQueryAsync(Function.createDelegate(this, this.onFeedbackQuerySucceeded),
Function.createDelegate(this, this.onFeedbackQueryFailed));
}
}
function onFeedbackQuerySucceeded(sender, args) {
$("#txtFeedback").val('');
}
function onFeedbackQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
var FeedbackClientContext;
var FeedbackWebsite;
var FeedbackCurrentUser;
var FeedbackList;
function AddFeedbackValue()
{
var FeedbackNoteValue= $.trim($("#txtFeedback").val()); // txtFeedback name of the text box html field
if(FeedbackNoteValue.length > 0)
{
FeedbackClientContext = new SP.ClientContext("/");
FeedbackWebsite = FeedbackClientContext.get_web();
FeedbackList = FeedbackWebsite.get_lists().getByTitle('Feedback'); // name of the SharePoint list
var FeedbackListItemCreInfo = new SP.ListItemCreationInformation();
var FeedbackNewItem = FeedbackList.addItem(FeedbackListItemCreInfo);
FeedbackNewItem.set_item('Feedback',FeedbackNoteValue);
FeedbackNewItem.update();
FeedbackClientContext.executeQueryAsync(Function.createDelegate(this, this.onFeedbackQuerySucceeded),
Function.createDelegate(this, this.onFeedbackQueryFailed));
}
}
function onFeedbackQuerySucceeded(sender, args) {
$("#txtFeedback").val('');
}
function onFeedbackQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Thanks,
-Sendil
No comments:
Post a Comment