I'm trying to help someone out with some javascript that works in IE but not in firefox.
It's basically a filter so you select some options from select boxes and the javascript hides or shows any table cell that is not needed.
The html is shocking and the javascript doesn't look too hot either but it works in IE so can't be all bad
Can anyone tell me why it works in IE and not firefox and how to get it working in firefox?
This is the javascript
function query() {
var vacancyRows = vacanciesTable.tBodies[0].rows;
var count = vacancyRows.length - 1;
var query = location.search;
//-- If there isn't a query --//
if(query == "" || query == "?category=&location=&skills=") {
//-- Do nothing! --//
}
//-- Else --//
else {
query = query.substr(1);
var queryParts = query.split("&");
for(var i = 0; i < queryParts.length; i++) {
var nameAndValue = queryParts[i].split("=");
var name = nameAndValue[0];
var value = nameAndValue[1].replace("/\+/g", " ");
for(var rowIndex = 1; rowIndex < vacancyRows.length; rowIndex++) {
var curRow = vacancyRows[rowIndex];
if(curRow.style.display == "none") continue;
switch(name) {
case "category" :{
//-- Put value in category select --//
searchForm.categorySelect.value = value;
//-- Hide rows that don't match this category --//
if(curRow.cells[1].innerText.indexOf(value) == -1) {
curRow.style.display = "none";
count--;
}
break;
}
case "location" :{
//-- Put value in location Select --//
searchForm.locationSelect.value = value;
//-- Hide rows that don't match this location --//
if(curRow.cells[6].innerText.indexOf(value) == -1) {
curRow.style.display = "none";
count--;
}
break;
}
case "skills" :{
//-- Put value in skills input --//
searchForm.skillsInput.value = value;
//-- Hide rows that don't match these skills --//
if(curRow.innerText.toLowerCase().indexOf(value.toLowerCase()) == -1) {
curRow.style.display = "none";
count--;
}
break;
}
}
}
}
vacanciesTable.style.display = "block";
messageDiv.style.display = "block";
if(count == 0) nomatchesElem.style.display = "block";
else matchesElem.style.display = "block";
}
}
I've attached the html page as it is too long to list here