how to check Title( Country) if exists in the list. if exists it is necessary to do the update if not it is necessary to add it ?
function AddListItem() {
var listTitle = "Test";
//Get the current client context
context = SP.ClientContext.get_current();
var airportList = context.get_web().get_lists().getByTitle(listTitle);
//Create a new record
var listItemCreationInformation = new SP.ListItemCreationInformation();
var listItem = airportList.addItem(listItemCreationInformation);
//Set the values
var country= $("#Country").val();
var client= $("#Client").val();
// var nb1 = $("#nb1").val();
// var nb2 = $("#nb2").val();
// var nb3 = $("#nb3").val();
// var nb4 = $("#nb4").val();
// // var nb5 = $("#nb5").val();
listItem.set_item('Country', Country);
listItem.set_item('Client', Client);
listItem.update();
context.load(listItem);
context.executeQueryAsync(AddListItemSucceeded, AddListItemFailed);
}
function AddListItemSucceeded() {
}
function AddListItemFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}