Znowu nie rozumiem o co chodzi i tu chyba mam największy problem

przydałyby się nieco konkretniejsze wskazówki, coś co pobudzi do myślenia na razie nie wiem w którą stronę iść mimo że problem wydaje się być bardzo podobny do ostatniego nie mam pomysłu jak to ogarnąć.
EDIT.Ponieważ w js mam już podobna działającą funkcję datepickera próbowałem na podobnej zasadzie dopisać obsługę autocomplete, niestety rezultat nie przyniósł chcianych efektów.
W chwili obecnej to mam:
$('button').on('click', function(event) {
event.preventDefault();
var lines = $('#lines');
var i = 0;
$('input.datepicker').datepicker("destroy");
lines.append(lines.find('li:first-child').clone());
$('.datepicker').each(function () {
$(this).attr("id",'datepicker' + i).datepicker();
i++;
});
});
$('input.datepicker').datepicker();
$( function() {
$( "#datepicker" ).datepicker();
} );
// autocomplet : this function will be executed every time we change the text
function autocomplet() {
var min_length = 1; // min caracters to display the autocomplete
var keyword = $('.ingredient').val();
if (keyword.length >= min_length) {
$.ajax({
url: 'ajax_refresh.php',
type: 'POST',
data: {keyword:keyword},
success:function(data){
$('#ingredient_list_id').show();
$('#ingredient_list_id').html(data);
}
});
} else {
$('#ingredient_list_id').hide();
}
}
// set_item : this function will be executed when we select an item
function set_item(item) {
// change input value
$('.ingredient').val(item);
// hide proposition list
$('#ingredient_list_id').hide();
}
Na próbę jak zrobię tak:
Kod
<li>
<input type="text" class="ingredient" name="ingredient[]" onkeyup="autocomplet()" autocomplete="off" value="" />
<ul id="ingredient_list_id"></ul>
<input type="text" class="datepicker" name="deliverydate[]" autocomplete="off" value="" />
</li>
<li>
<input type="text" class="ingredient" name="ingredient[]" onkeyup="autocomplet2()" autocomplete="off" value="" />
<ul id="ingredient_list_id"></ul>
<input type="text" class="datepicker" name="deliverydate[]" autocomplete="off" value="" />
</li>
i
Kod
$('button').on('click', function(event) {
event.preventDefault();
var lines = $('#lines');
var i = 0;
$('input.datepicker').datepicker("destroy");
lines.append(lines.find('li:first-child').clone());
$('.datepicker').each(function () {
$(this).attr("id",'datepicker' + i).datepicker();
i++;
});
});
$('input.datepicker').datepicker();
$( function() {
$( "#datepicker" ).datepicker();
} );
// autocomplet : this function will be executed every time we change the text
function autocomplet() {
var min_length = 1; // min caracters to display the autocomplete
var keyword = $('.ingredient').val();
if (keyword.length >= min_length) {
$.ajax({
url: 'ajax_refresh.php',
type: 'POST',
data: {keyword:keyword},
success:function(data){
$('#ingredient_list_id').show();
$('#ingredient_list_id').html(data);
}
});
} else {
$('#ingredient_list_id').hide();
}
}
function autocomplet2() {
var min_length = 1; // min caracters to display the autocomplete
var keyword = $('.ingredient').val();
if (keyword.length >= min_length) {
$.ajax({
url: 'ajax_refresh.php',
type: 'POST',
data: {keyword:keyword},
success:function(data){
$('#ingredient_list_id').show();
$('#ingredient_list_id').html(data);
}
});
} else {
$('#ingredient_list_id').hide();
}
}
// set_item : this function will be executed when we select an item
function set_item(item) {
// change input value
$('.ingredient').val(item);
// hide proposition list
$('#ingredient_list_id').hide();
}
Drugi input nie działa, tzn. nie ma podpowiedzi w ogóle, pierwszy input działa normalnie z tym że wybrana opcja pojawia się w wszystkich inputach.