Welcome to WebmasterWorld Guest from 54.144.108.92

Forum Moderators: open

Message Too Old, No Replies

Trouble with list index in NN7

Sorry for the newbie question

     
7:00 am on Jul 16, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 18, 2003
posts:77
votes: 0


Hi

I have a for loop that runs perfectly well under IE6 but does nothing under Netscape 7.1 and I was wondering if there's a work around.

I have a list called region on a form and I'm passing the form as the parameter "thisform".

During debug I've found that the script just stops at thisform.region(idx).selected - no error - just stops.

Here's the piece of code that's failing:
===========================

for (idx = 0; idx < thisform.region.length ; idx++)
{if (thisform.region(idx).selected == true)
{regions ++
};
}

===========================

any ideas
Thanks

10:27 am on July 16, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


IE allows you to access some collections via ( ) notation, rather than [ ]. Netscape doesn't. So all you need to do is change (idx) to [idx]:


var idx, region = thisform.regions
for (idx = 0; idx < region.length ; idx++)
if (region[idx].selected)
regions ++

/* maybe more 'correct':

region.options[idx]
// or
region.options.item(idx) //!

*/

12:32 pm on July 16, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 18, 2003
posts:77
votes: 0


Thanks Heaps Bernard!

I should have known the problem was with IE not NN

1:19 pm on July 16, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


MS doesn't need me to fight it's battles, but...
I think the problem doesn't lie with IE, rather (ahem) somewhere else ;)

..but seriously now, IE has inbuilt backward-compatibility with old methods, and features a number of convenience properties etc. Its standards support could be described as "not what it could be", but it's not that bad. In our case, IE wasn't guilty of anything other than offering an alternative.

The problem comes when people (me included) learn the IE-only techniques first, without realising (or being informed) that they are proprietary.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members