Forum Moderators: open
my HTML
<input type="image" src="btn_a.gif" name="btn_1" id="btn_1" />
<input type="image" src="btn_a.gif" name="btn_2" id="btn_2" />
<input type="hidden" name="num" id="num" value="1,2,3" />
<img src="spcr.gif" onload="check()" />
function check(){
var r_num = document.getElementById('num');
var r_num_arr = new Array();
r_num_arr = r_num.value.split(',');
for ( var i = 0; i < r_num_arr.length; i++ ){
alert(r_num_arr[i]);
var num = r_num_arr[i];
var button = document.getElementById('btn_' + num);
button.src = btn_b.gif';
}
}
The interesting thing is that if I use the alert it works - I still get the error "button has no properties" but it works. If i comment out the alert it doesn't work - but i still get the error.
Anyone understand what's going on here?
Please help!
Also just restating (perhaps irrelevant): the hidden field "num" is not prepopulated - it's populated on runtime.