473,529 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1168
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
2820
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 decode. I have done a conversion to pyrex and have gotten it down to about 2 seconds to run both encode and decode. An an excerpt from the pyrex...
6
12277
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 null for length. Fine and logical if the number of boxes is fixed or >2, a pain if the range is 1 or more. I need to check for a returned...
7
39828
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
6666
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
5506
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 of characters, they store one less with a null at the end! Whats the point in a marshalling as fixed length if it wastes space with a null! How can...
13
9788
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 response.GetResponseStream() also empty. However, I am able to open the URL in the browser (the URL address remains the same; it is not redirected) Here...
4
2380
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#. But the compiler complains: C:\Inetpub\wwwroot\passwordProtectCSharp\adminUserFile.aspx.cs(333): Cannot
3
1220
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 child(0) As Object Array.Resize(Of Object)(child, 0) Return child
4
2796
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 values). The problem is that if I assign it to something other than an integer, it complains and throws an exception: MyArr = new SomeObject();...
4
11231
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 set the buffer? In specific, my question is what causes the 'completed' event in the OnSocketConnectCompleted method to fire? Does it fire at end of...
0
7350
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7272
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7672
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7260
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5202
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3336
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1722
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
902
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.