PDA

View Full Version : setting a style via document.getElementById not working



jasper502
02 May 2010, 07:42 PM
Here is the code:

http://www.gridlocate.ca

If you change the 'Meridian' to '4' and hit the 'Locate' button the map does it's magic and the updatelegend function gets called. I know it does because if I uncomment the alert test call the proper twn value gets displayed.

The idea is that the style of the corresponding section & township squares on the sidebar are updated. If I manually enter the inputs along the way the style gets updated. Now that I think about it the issue must be with the input data. Perhaps I need to change the variable type??

Dan

function updatelegend(twn,sec) {

// echo twn;

// alert(twn);
var twn = 't' + twn;
var sec = 's' + sec;

// alert(twn);

document.getElementById(twn).style.borderWidth = "2px";
document.getElementById(twn).style.borderColor = "blue";

document.getElementById(sec).style.borderWidth = "2px";
document.getElementById(sec).style.borderColor = "red";


}

jasper502
02 May 2010, 10:44 PM
Stupid me... I had padded zeros in my pop-ups but not in my div id's.
Dan :^)