View Full Version : Switch Content Script

01-23-2006, 08:50 PM
Script: Switch Content
URL: http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

I have found an interesting issue with this script. When the collapsible content area contains an <input> tag with the name 'length', the script fails! It took me some time before I figured this one out! I completely gutted my page before I did, but naming the input tag 'length' was the culprit. I also tried just having the word length in there, but that was OK. It only seems to happen when I name the tag length. I even copied the code on the page and it worked great until I added the input tag.

So I hope this qualifies as a bug! If it does does that mean I get a cookie or something? I like chocolate chip, but a peanut butter cookie sounds good right now too.

Anywho, hopefully someone can respond to this and let me know what's up with this one.


01-24-2006, 08:53 AM
Length is a reserved word. Not perhaps in any particular sense, though it may be. However, when you tell a browser that name=length, you are saying that one attribute equals another. Especially if you do it without quotes as I have just done. If you were to use name="length", it would be less likely to cause a problem but , who knows? How did you have it? In any case, I wouldn't call that a bug of the script. If you used quotes, I'd call it a browser bug. If you used it without quotes, simply sloppy coding.

01-24-2006, 02:11 PM
Very interesting. I tried duplicating the problem, and it seems to only occur in IE (not Firefox, for example). This isn't a script of the bug as far as I can see though- in theory, you're free to use any HTML within the content to be expanded/collapsed, as all the script does is manipulate the display property of the container for each content, not the actual content. The fact that name="length" trips up IE can only be explained by an internal bug with the browser.

01-24-2006, 02:39 PM
Thanks guys, it must be an IE issue then. Yes jscheuer1, I did use quotes, single and double. No sloppy coding here. :) I was thinking that if the ID attribute of the input tag was 'length', that could account for the issue, as the script uses getelementbyid(), and perhaps somewhere that was mucking it up, but not the name attribute. Anywho, thanks all for checking this out! Guess I'll have to wait on my cookie till another day!