This should be simple, but it's not working for me! The relevant code is beneath.
This code is on my html page directly under the input field:
input = document.getElementById('hiddenInput');
var inputInt = parseInt(input.value);
if (inputInt != 0) {
setClick(inputInt);
}
(I've tested it to make sure it sees the input object and that it has the correct value. It does call the setClick function appropriately, too.)
This code is in a javascript file called in the <head> of the html page:
function setClick(num) {
input.value = num;
resetAll();
obj = eval('document.port' + num);
obj.src = portThumbActive[num-1];
obj.name = ('active');
obj = eval('document.nav' + num);
obj.src = navActive[num-1];
obj.name = ('active');
}
function resetAll () {
for ( var c=1; c<= navNormal.length; c++) {
obj = eval('document.nav' + c);
obj.src = navNormal[c - 1];
obj.name = ('nav' + c);
}
for ( var c=1; c<= portThumb.length; c++) {
obj = eval('document.port' + c);
obj.src = portThumb[c - 1];
obj.name = ('port' + c);
}
}
setClick() and resetAll() work great when I hook setClick() up to a link. When I try to grab the value from the input field, it doesn't even call resetAll(). I've assumed that it's a problem with converting the value to an integer, but I could be wrong. Does anyone have an idea as to what's going on?