; skillIds = skills.map(e => { return e.id }) $.each(selectedSkillIds, (i, id) => { idx = skillIds.indexOf(parseInt(id)) if (idx != -1) { v = skills[idx] selected = ''; $("#tags__selected").append(selected); } }) } if (WorkerTypeId) $("#jobType").val(WorkerTypeId) if (Education) $("#education").val(Education) if (Experience) $("#experience").val(Experience) if (minsalary != undefined && maxsalary != undefined) { salaryRangeSlider.update({ from: minsalary, to: maxsalary }) $("#event-receiver").val(minsalary + "," + maxsalary) } if (rating > 0) { var ratings = ["", "one", "two", "three", "four", "five"]; $("#" + ratings[rating]).click() } } if (0) restoreSearchForm() else localStorage.setItem("rating", "0") }); p; |   Need help? ; skillsAuto = []; for (i = 0; i < skills.length; i++) { skillsAuto.push(skills[i].name); } $("#skills").autocomplete({ minLength: 3, source: skillsAuto, select: function (event, ui) { $.each(skills, function (i, v) { if (v.name == ui.item.value) { tmp = $("#skillsChosen").val(); if (!tmp.includes(v.id)) { if (tmp == "") { tmp = v.id; } else { tmp += ',' + v.id } $("#skillsChosen").val(tmp); //selected = $("#tags__selected").val(); selected = ''; $("#tags__selected").append(selected); $("#skills").val(""); } return; } }); return false; }, //HERE - make sure to add the comma after your select response: function (event, ui) { if (!ui.content.length) { var noResult = { value: "", label: "Skill not found" }; ui.content.push(noResult); } } })