Hello I am trying to make a redirect of search results from my search bars but it returns all the search results to the very last statement I make in the function
HTML
<input type="text" class="educationSearchBar" id="calculatorSearch" placeholder="Type an Equation Name or the equation" list="educationList">
<div id="educationListOutput"></div>
JS to show the datalist
var industries = '<datalist id="educationList"> \
<option value="Algebra"></option> \
<option value="Analytical Chemistry"></option> \
<option value="Chemistry"></option> \
<option value="Economics"></option> \
<option value="Financial Acounting"></option> \
<option value="Geometry"></option> \
<option value="Managerial Accounting"></option> \
<option value="Organic Chemistry"></option> \
<option value="Physics"></option> \
<option value="Precalculus"></option> \
</datalist>';
var educationList = document.querySelector('#educationListOutput');
educationList.innerHTML = industries;
here is the JS for the search redirection
var inputSearchCalc = document.querySelector('#calculatorSearch').value;
var searchCalcBtn = document.querySelector('#search-calculator-index');
function searchCalc() {
if (inputSearchCalc = 'Algebra') {
window.location = '/educationSec/calculatorSubjects/algebra/algebra.html'
}
if (inputSearchCalc = 'Analytical Chemistry') {
window.location = '/educationSec/calculatorSubjects/AChem/AChem.html'
}
if (inputSearchCalc ='Chemistry') {
window.location = '/educationSec/calculatorSubjects/chemistry/chemistry.html'
}
if (inputSearchCalc = 'Economics') {
window.location = '/educationSec/calculatorSubjects/economics/economics.html'
}
if (inputSearchCalc = 'Financial Accounting') {
window.location = '/educationSec/calculatorSubjects/finAccounting/finAccounting.html'
}
if (inputSearchCalc = 'Geometry') {
window.location = '/educationSec/calculatorSubjects/geometery/geometery.html'
}
if (inputSearchCalc = 'Managerial Accounting') {
window.location = '/educationSec/calculatorSubjects/manAccounting/manAccounting.html'
}
if (inputSearchCalc = 'Organic Chemistry') {
window.location = '/educationSec/calculatorSubjects/organicChem/organicChem.html'
}
if (inputSearchCalc = 'Physics') {
window.location = '/educationSec/calculatorSubjects/physics/physics.html'
}
if (inputSearchCalc = 'Precalculus') {
window.location = '/educationSec/calculatorSubjects/precalc/precalc.html'
}
}
searchCalcBtn.addEventListener('click' , searchCalc);
All of the results redirect to the precalc page which is the last one
Aucun commentaire:
Enregistrer un commentaire