I have the following select on my JSP file:
<select id="order-select">
<option value="Lowest price" onclick="sortLowestPrice()"><spring:message code="list.lowest"/></option>
<option value="Highest price" onclick="sortHighestPrice()"><spring:message code="list.highest"/></option>
</select>
Turns out I never get to call sortLowestPrice() or sortHighestPrice(). I know my JS works because other functions on it get called in the same JSP and they work fine.
Here's one of those functions:
function sortHighestPrice() {
console.log("im here");
var publications = document.querySelectorAll(".polaroid-property");
var sort = [];
var father = document.getElementById("publications");
var i, j, k;
var max = null;
while (father.firstChild) {
father.removeChild(father.firstChild);
}
for(i = 0; i < publications.length; i++){
max = null;
for(j = 0; j < publications.length; j++){
if(publications[j].getAttribute("visited") != "true"){
var price = parseInt(publications[j].getElementsByClassName("price-tag")[0].innerHTML.substring(1));
if(price > max || max == null){
max = price;
k = j;
}
}
}
sort.push(k);
publications[k].setAttribute("visited",true);
}
for(i = 0; i < sort.length; i++){
publications[i].setAttribute("visited",false);
father.appendChild(publications[sort[i]]);
}
}
I never get 'im here' on the browser log.