473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Length is Object???

I am running a bit of JS to highlight text inputs onFocus in IE. It
seems to be working on all of the forms on the site except one. The
debug code in the script displays the number of input elements in an
alert. On the page where it does not work, the alert is "[object]".

Here is the script:

function initHighlight() {
if (!document.getElementsByTagName){ return; }
var allfields = document.getElementsByTagName("input");
alert (allfields.length); // debug
for (var i=0; i<allfields.length; i++){
var field = allfields[i];
var attr = field.getAttribute("type");
if (attr == "text" || attr == "password") {
field.onfocus = function () {
this.className = 'highlightActiveField';
}
field.onblur = function () {this.className =
'highlightInactiveField';}
}
}
}

function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function'){ window.onload = func; }
else { window.onload = function() { oldonload(); func(); } }
}

var isIE = navigator.appName.indexOf("Microsoft") != -1;
if (isIE) { addLoadEvent(initHighlight); }

Unfortunately, I cannot reveal the URL of the page (contractural
restrictions).

Under what conditions would IE believe that the length of input fields
is an object, not a number? I have run the page through two
different validators and there are no errors.

TIA!
Aug 19 '06 #1
2 1167
Tyrone Slothrop wrote:
<snip>
var allfields = document.getElementsByTagName("input");
alert (allfields.length); // debug
<snip>
Under what conditions would IE believe that the length of
input fields is an object, not a number?
<snip>

Whenever the NAME and/or ID attribute of an IPUT element was "length".

Richard.
Aug 19 '06 #2
On Sat, 19 Aug 2006 22:36:58 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.ukwrote:
>Tyrone Slothrop wrote:
<snip>
> var allfields = document.getElementsByTagName("input");
alert (allfields.length); // debug
<snip>
>Under what conditions would IE believe that the length of
input fields is an object, not a number?
<snip>

Whenever the NAME and/or ID attribute of an IPUT element was "length".

Richard.
<slaps forehead Well, wouldn't you know there is an input called
length in that form. Renemed it and it works.

Thanks!
Aug 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Lambacher | last post by:
Hi, I have to do some data manipulation that needs to be fast. I had a generator approach (that was faster than a list approch) which was taking approximately 5 seconds to run both encode and...
6
by: Mark Anderson | last post by:
I'm getting a bit confused, it seems a checkbox object only has a length value if there is more than one checkbox of that name, 2 checkboxes named 'box' have a length of 2 but a single box returns...
7
by: Robert Mark Bram | last post by:
Hi All! How do you get the length of an associative array? var my_cars= new Array() my_cars="Mustang"; my_cars="Station Wagon"; my_cars="SUV"; alert(my_cars.length);
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
1
by: Tajmiester | last post by:
Hi, And thanks for any help. I am having trouble declaring a struct containing strings that can be Serialized using the following functions. It works, but the strings wont store the right number...
13
by: Jason Manfield | last post by:
For some URLs (e.g.http://v3.espacenet.com/origdoc?DB=EPODOC&IDX=WO2005028634&F=0&QPN=WO2005028634), the content length for the HttpWebResponse I get with request.GetResponse in empty. The...
4
by: dale zhang | last post by:
Hi, I am trying to save an image to MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp For save button, I converted his VB to the following C#....
3
by: Nathan M | last post by:
Hi, Using VB 2005, I have a function that returns an array of a certain object. In certain cases the function should return an array with a length of 0. I've found that this works: Dim...
4
by: Kozman | last post by:
I have a problem where I need to use the literal "length" as a subscript in an associative array (I have no control over what is used as a subscript..."length" happens to be one of the uncontrolled...
4
by: danomano | last post by:
The code below works fine. As of now I just set the buffer length real big and all is good. However, I hate the impreciseness of that. So my question in general is how do I know what length to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.