You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PROJET-WEB_STRI1A/WEB/recherche/recherche.js

25 lines
1.0 KiB
JavaScript

$(document).ready(function () {
//copy options
let options = $('#villeDepart option').clone();
//react on keyup in textbox
$('#villeDepartText').keyup(function () {
let val = $(this).val().toString().toLowerCase();
$('#villeDepart').empty();
//take only the options containing your filter text or all if empty
options.filter(function (idx, el) {
return val === '' || $(el).text().toLowerCase().indexOf(val) >= 0;
}).appendTo('#villeDepart');//add it to list
});
//copy options
let optionsArrive = $('#villeArrive option').clone();
//react on keyup in textbox
$('#villeArriveText').keyup(function () {
let val = $(this).val().toString().toLowerCase();
$('#villeArrive').empty();
//take only the options containing your filter text or all if empty
optionsArrive.filter(function (idx, el) {
return val === '' || $(el).text().toLowerCase().indexOf(val) >= 0;
}).appendTo('#villeArrive');//add it to list
});
});