I'm looking for an easier way to process through these multiple If Else statements, there are several hundred. I'm guessing it would be best to just use another For loop inside of the If Else, but let me know you all suggest, thanks!
var hrefs = [];
var list = document.getElementsByTagName("a");
for (var i=0; i<list.length; i++) {
var hey = list[i].href;
hrefs.push(hey);
}
if(window.location == 'http://') {
tileid = <?php echo $numposts.''; ?>;
} else if (window.location == hrefs[7]) {
tileid = 0;
} else if (window.location == hrefs[8]) {
tileid = 1;
} else if (window.location == hrefs[9]) {
tileid = 2;
} else if (window.location == hrefs[10]) {
tileid = 3;
} else if (window.location == hrefs[11]) {
tileid = 4;
} else if (window.location == hrefs[12]) {
tileid = 5;
} else if (window.location == hrefs[13]) {
tileid = 6;
} else if (window.location == hrefs[14]) {
tileid = 7;
} else if (window.location == hrefs[15]) {
tileid = 8;
} else if (window.location == hrefs[16]) {
tileid = 9;
} else if (window.location == hrefs[17]) {
tileid = 10;
} else if (window.location == hrefs[18]) {
tileid = 11;
} else {
tileid = window.history.state.projid;
}
tileid = 0correspond to the 7th link?- 7forloop inside the firstforloop or you can put all the hrefs into an object and use direct object property lookup.tileid = hrefs.indexOf(window.location) - 7