i work with prestashop1.7. The Search by Brand works perfectly under the form "dropdown list" in the module ps_facetedSearch.
I need to override this search instead of dropdown i need an input field, So i think that the solution can be to search if the inputed text is exist in the dropdown list. this is my essay but the console display no despite console log on txtValue and inpted showContent of these variables. that's why i need your help concerning the script js itself that must test if inputed text exist in the dropdown list.
code html of the module faceted search
<div class="dropdown-menu" id="dropdown-menu">
<a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Naim+Ameur" class="select-list"> Naim Am(1)</a>
<a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Sonia+Mili" class="select-list"> Sonia Mili (1) </a>
<a rel="nofollow" href="http://archivartshop.local/fr/2-accueil?q=Marque-Yosr+Ben+Hammouda" class="select-list"> Yosr Ben Houda(2)</a>
</div>
My essay script js
function mFn(){
divLi = document.getElementById("dropdown-menu");
linka = divLi.getElementsByTagName("a");
for (i = 0; i < linka.length; i++) {
var txtValue = linka[i].textContent ;
// console.log(txtValue); content displayed
var inpted = $('#search_input').val();
// console.log(inpted);content displayed
if( txtValue === inpted)
{
console.log("it_works");
}
else {
console.log("No !!");
}
}
}
I would be very grateful for your help
Now it works for me
function mFn(){
divLi = document.getElementById("dropdown-menu");
linka = divLi.getElementsByTagName("a");
for (i = 0; i < linka.length; i++) {
var txtValue = linka[i].textContent ;
// console.log(txtValue); content displayed
var inpted = $('#search_input').val();
// console.log(inpted);content displayed
if( txtValue.includes(inpted) )
{
console.log("it_works");
}
else {
console.log("No !!");
}
}
}