I have an ajax autocomplete script and I'm trying to merge two $(document).on('click'
into one so that when you make a single click the two are copied at the same time in their corresponding fields but I do not get it possible?
$(document).on('click', '.datalistdes', function(){
$('#nombre1').val($(this).text());
$('#Listdes').fadeOut();
}).on('click', '.linkdata', function(){
$('#nombre2').val($(this).text());
$('#Listdes').fadeOut();
});
<div class="form-group">
{{ Form::text('nombre1', null, ['class' => 'from-control', 'id' => 'nombre1']) }}
</div>
<div class="form-group">
{{ Form::text('nombre2', null, ['class' => 'from-control', 'id' => 'nombre2']) }}
</div>
Right now, it works well for me when I click on one, I fill it in and click on the other one, but what I need is for both to be filled in with a single click.