[thelist] JS Problem - IE throwing 'null or not an object' error

Blake haswell00 at gmail.com
Wed May 14 21:40:27 CDT 2008

Hi List,

I'm having a problem in IE with the following snippets of code.
Firefox works as expected.

The error in IEs error console says that 'style' is null or not an
object. From my exploration it seems that the
getShoppingDescriptions() function is returning an object but it's
length property is 0, so I assume no LI elements are being found. The
LIs are not direct descendants of #description, but I don't see why
that would make a difference because I have a similar situation in
another script that works fine.

Any ideas?

-- CODE --

// Get the descriptions
function getShoppingDescriptions() {
	if(document.getElementById('description')) {
		return document.getElementById('description').getElementsByTagName('li');
	else {
		return false;

// Hide all descriptions and display the one you want
function swapDescriptions(selectedDescription) {
	var description;
	if(description = getShoppingDescriptions()) {
		for(var i = 0; i < description.length; i++) {
			description[i].style.display = 'none';
		description[selectedDescription].style.display = 'block';

More information about the thelist mailing list