I have a SharePoint list called "Products" (containing 4 columns - Product, Manager, Approver, Status)
I have a dropdown list that populates the 'Product' column of the 'Products' list.
Say I select 'Soap' from the dropdown list, the corresponding value to 'Soap' is 'Mr.XYZ' as the approver in the 'Approver' column of the 'Products' list.
So upon selecting 'Soap' in the dropdown, I want the value 'Mr.XYZ' to be populated in a HTML Textbox.
I have achieved populating the dropdown using REST API and it works as expected as follows:
appendProducts();
function appendProducts() {
$.ajax({
url: "https://abc/_api/web/lists/GetByTitle('Products')/items?$select=Title",
type: "get",
dataType: 'json',
headers: {
"Accept": "application/json;odata=verbose"
},
success: function (data) {
var values = [];
var uniqueValues = [];
var option = "";
var valuesArray = data.d.results;
$.each(valuesArray, function (i, result) {
values.push(result.Title);
});
$.each(values, function (i, el) {
if ($.inArray(el, uniqueValues) === -1) {
uniqueValues.push(el);
option += "<option value='" + el + "'>" + el + "</option>";
}
});
$("#ddlProducts").append(option);
},
error: function (data) {
alert(data.responseJSON.error);
}
});
}
The following is my textbox ID:
<input id="txtapprover" />
Please help me populating the Textbox with the corresponding value selected in the dropdown. How can this be achieved best?
Thanks in advance :)