Ogre11
12-14-2006, 05:27 PM
This is completely inexplicable.
The function below gets all forms on the page, gets all form fields in each form and sets each field's onblur and onfocus event handlers to change the css class name. IE7 seems to think my form doesnt have any input fields, and when I alert the length of the fields[0] array I don't get undefined, or null or "", I get [object]! same when I alert fields[0].length.toString() and forms[0].getElementsByTagName('input').length and forms[i].getElementsByTagName('input').length.toString();
It doesn't throw any exceptions when i run it and it works fine in Firefox 2, FireBug even thinks the script is fine (which it is :mad: )
I even tried creating a separate for loop outside the rest of the functionality just for the array of input tags and still nothing!!
here is the page so you can see for yourself http://www.pedigreepalace.com/account/listdog.cfm
THIS MAKES NO SENSE!! :(
//sets the classes for all form objects when they blur and focus
function setBlurAndFocus()
{
var forms = document.getElementsByTagName('form');
for(var i = 0; i < forms.length; i++)
{
var fields = new Array();
var totWidth = 0;
fields[0] = forms[i].getElementsByTagName('input');
fields[1] = forms[i].getElementsByTagName('select');
fields[2] = forms[i].getElementsByTagName('textarea');
for(var k = 0; k < fields.length; k++)
{
//alert(forms[i].getElementsByTagName('input').length + ', ' + j);
for(var j = 0; j < fields[k].length; j++)
{
//alert(k + ', ' + j);
if(fields[k][j].tagName == "INPUT")
{
if(fields[k][j].type != "submit" && fields[k][j].type != "button")
{
if(fields[k][j].type != "file")
{
totWidth += fields[k][j].offsetWidth;
}
fields[k][j].className = 'blur';
fields[k][j].onblur = function()
{
this.className = 'blur';
}
fields[k][j].onfocus = function()
{
this.className = 'focus';
}
}
}
else
{
fields[k][j].className = 'blur';
fields[k][j].onblur = function()
{
this.className = 'blur';
}
fields[k][j].onfocus = function()
{
this.className = 'focus';
}
}
}
}
/*var fieldSets = forms[i].getElementsByTagName('fieldset');
for(var x = 0; x < fieldSets.length; x++)
{
if(fieldSets[x].style.width == undefined || fieldSets[x].style.width == "")
{
fieldSets[x].style.width = Math.round(totWidth / fields[0].length) + "px";
}
}*/
}
}
The function below gets all forms on the page, gets all form fields in each form and sets each field's onblur and onfocus event handlers to change the css class name. IE7 seems to think my form doesnt have any input fields, and when I alert the length of the fields[0] array I don't get undefined, or null or "", I get [object]! same when I alert fields[0].length.toString() and forms[0].getElementsByTagName('input').length and forms[i].getElementsByTagName('input').length.toString();
It doesn't throw any exceptions when i run it and it works fine in Firefox 2, FireBug even thinks the script is fine (which it is :mad: )
I even tried creating a separate for loop outside the rest of the functionality just for the array of input tags and still nothing!!
here is the page so you can see for yourself http://www.pedigreepalace.com/account/listdog.cfm
THIS MAKES NO SENSE!! :(
//sets the classes for all form objects when they blur and focus
function setBlurAndFocus()
{
var forms = document.getElementsByTagName('form');
for(var i = 0; i < forms.length; i++)
{
var fields = new Array();
var totWidth = 0;
fields[0] = forms[i].getElementsByTagName('input');
fields[1] = forms[i].getElementsByTagName('select');
fields[2] = forms[i].getElementsByTagName('textarea');
for(var k = 0; k < fields.length; k++)
{
//alert(forms[i].getElementsByTagName('input').length + ', ' + j);
for(var j = 0; j < fields[k].length; j++)
{
//alert(k + ', ' + j);
if(fields[k][j].tagName == "INPUT")
{
if(fields[k][j].type != "submit" && fields[k][j].type != "button")
{
if(fields[k][j].type != "file")
{
totWidth += fields[k][j].offsetWidth;
}
fields[k][j].className = 'blur';
fields[k][j].onblur = function()
{
this.className = 'blur';
}
fields[k][j].onfocus = function()
{
this.className = 'focus';
}
}
}
else
{
fields[k][j].className = 'blur';
fields[k][j].onblur = function()
{
this.className = 'blur';
}
fields[k][j].onfocus = function()
{
this.className = 'focus';
}
}
}
}
/*var fieldSets = forms[i].getElementsByTagName('fieldset');
for(var x = 0; x < fieldSets.length; x++)
{
if(fieldSets[x].style.width == undefined || fieldSets[x].style.width == "")
{
fieldSets[x].style.width = Math.round(totWidth / fields[0].length) + "px";
}
}*/
}
}