boxcfed is not defined - error in firefox, works fine in IE


M

mehstg1319

Hi everybody

Was wondering if anybody could help. I am a student, developing a
couple of pages for my university.

I am getting a problem with a javascript Hide/Show that I have put on
the page (the vertical links on the left of the grid are the only
links i have implemented this on at the moment). The javascript seems
to work fine in IE6, but in Firefox, i get an error in the Error
Console telling me that 'boxcfed is not defined' where boxcfed is the
name of one of the divisions I wish to hide.

Any ideas?

Here is a link to the page
http://homepages.feis.herts.ac.uk/~bp6ar/bus_intel/matrix/index.html

Thanks in advance

Paul
 
Ad

Advertisements

S

SAM

mehstg1319 a écrit :
I am getting a problem with a javascript Hide/Show that I have put on
the page (the vertical links on the left of the grid are the only
links i have implemented this on at the moment). The javascript seems
to work fine in IE6, but in Firefox, i get an error in the Error
Console telling me that 'boxcfed is not defined' where boxcfed is the
name of one of the divisions I wish to hide.

Any ideas?

you forgot document.getElementById()
on each line of hideAll()

function $(what) {
return (typeof what == 'string')?
document.getElementById(what) : what;
}
function showMe(id) {
hideAll();
$(id).style.display = "";
return false;
}

function hideAll() {
$('boxcfed').style.display = "none";
$('boxgcu').style.display = "none";
$('boxbdc').style.display = "none";
$('boxenterprise').style.display = "none";
$('boxgradfutures').style.display = "none";
$('boxget').style.display = "none";
$('boxplacements').style.display = "none";
$('boxbpo').style.display = "none";
$('boxkt').style.display = "none";
$('boxbpoadmin').style.display = "none";
$('boxspc').style.display = "none";
$('infobox').style.display = "none";
}

<li><a href="#" onclick="return showMe('boxcfed')">
<li><a href="#" onclick="return showMe('boxgcu')">
etc ...


variant :
=========

function $(id) { return document.getElementById(id); }

function showMe(id) {
for(var i in sections) $(sections).style.display = 'none';
$(id).style.display = "";
return false;
}

var sections = [
'boxcfed', // comment
'boxgcu', // comment (what it is !)
'boxbdc', // comment (for later development)
'boxenterprise',
'boxgradfutures',
'boxget',
'boxplacements',
'boxbpo',
'boxkt',
'boxbpoadmin',
'boxspc',
'infobox'
];
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top