I just realized I posted this here instead of the javascript folder... can a moderator move it there, by any chance? thanks!
Hi,
I've got a script that works, but is returning an error in Firebug:
- HTML: Select all
var thirdpngs = document.getElementsByName('last');
function showit(){
for (iName in thirdpngs){
thirdpngs[iName].style.display = 'inline';
}
}
function hideit(){
for (iName in thirdpngs){
thirdpngs[iName].style.display = 'none';
}
}
The error is "thirdpngs[iName].style has no properties"
I'm puzzled because:
- HTML: Select all
var thirdpngs = document.getElementsByName('last');
function showit(){
thirdpngs[0].style.display = 'inline';
thirdpngs[1].style.display = 'inline';
thirdpngs[2].style.display = 'inline';
}
function hideit(){
thirdpngs[0].style.display = 'none';
thirdpngs[1].style.display = 'none';
thirdpngs[2].style.display = 'none';
}
doesn't return any errors.
Fixed:
- HTML: Select all
var thirdpngs = document.getElementsByName('last');
function showit(){
for (var i = 0; i <= 2; i++) {
thirdpngs[i].style.display = 'inline';
}
}
function hideit(){
for (var i = 0; i <= 2; i++) {
thirdpngs[i].style.display = 'none';
}
}
-------------
[at least in Firefox; script doesn't work in IE7...)