Hello, there is such a script and the problem happens that when you select the previous option, it does not replace values here, but adds. Tried to make $("#selectf-"+ dataitemspl).empty()append(dispcity); so it deletes completely, that is, with value='0' is deleted too, but you need to leave it and delete only the others, and then it will be added accordingly.
var dataitemspl = ++dataitems; for (var i = 0; i < infooption.length; i++) { var dispcity = dispcity +"<option value='"+ infooption[i] +"'>"+ infooption[i] +"</option>"; } $("#selectf-"+ dataitemspl).append(dispcity); <select id="selectf-2" name="selectf" data-item="2" data-name="city" style=""> <option value="0">Выберите город</option> <option value="Аликанте">Аликанте</option> <option value="Барселона">Барселона</option> <option value="Мадрид">Мадрид</option> <option value="Малага">Малага</option> </select>