I have to get other column value of list item whose "Title" matches with entered string in text box from the page. I am using CAML query to match "Title". But in Success function, how to get that item's other field like ...Title, Department etc.. Below if my tried code.
Code in CEWP:
<input name="pop" id="pop" type="text"/> <input name="b1" id="b1" onclick="getTheList()" type="button" value="Submit"/><script>
function getTheList() {
alert('inside getTheList fucntion');
var test=$("#pop").val();
alert(test);
clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var myList = web.get_lists().getByTitle('URL_List');
var query = new SP.CamlQuery();
query.set_viewXml('<View><Query><Where><Eq><FieldRef Name="Title"/><Value Type="Text">+ test + </Value></Eq></Where></Query></View>');
this.ListItem = myList.getItems(query);
clientContext.load(ListItem,'title');
clientContext.executeQueryAsync(Function.createDelegate(this, this.mySuccessFunction), Function.createDelegate(this, this.myFailFunction));
return false;
}
function mySuccessFunction(sender, args)
{
alert('Success');
var title = this.ListItem.get_item("Title");
alert(title);
//how to get title and other field if an Item here...??
}
function myFailFunction(sender, args)
{
alert('inside fail');
alert("GetListItemById Failed. \n" + args.get_message() + "\n" + args.get_stackTrace());
}</script>