0

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?

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by vsmash
0

I reckon:
1. Don't use 'input' as a var - it is a reserved word
2. if the hiddeninput is a form field call it that way:

inputvar=document.formname.hiddenInput.value;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.