I am dynamically getting the value of an input element of type='password' in an HTML form reading its password, then creating a text input element and sticking it into that one to reveal the secret password. It works fine when I don't apply a CSS class name to the created text input element. But if I do then the foreground text is always invisible. If I click the text with my mouse and drag my cursor over it, to select the text then I can see the text. Then after clicking again to deselect the text, the text appears correctly with the appropriate style applied! If I set a specific foreground color for the text it has no effect to this behavior. The text is still invisible. If I set a specific background color, the background color works correctly and shows up immediately after I add the created text input element, but the foreground text color is always invisible until I mess with it by manually selecting some text and unselecting it.
Note: I am running in IE 6.
Here's my Javascript code:
var n = document.getElementById("PASSWORD_FIELD");
var elm = document.createElement('input');
elm.value = n.value;
elm.size = "11";
elm.type = "text";
elm.name = "PASSWORD_FIELD";
//This next line is what causes the weird behavior...
elm.className = "myStyleClass";
var parent = n.parentNode;
parent.removeChild;
parent.insertBefore(elm,parent.firstChild);
--
I've tried adding a foreground color and a background color to my style like this...
.myStyleClass {font-family:Verdana;font-size:10pt;color:FF0000;background-color:#6666CC;}
But the problem seems to happen no matter how I style this. The only way to avoid it that I can see, is to not set a style to the className attribute. But I'd like to be able to set a style.
I can't understand why this is happening or how to fix it. Any ideas or thoughts?
Thanks,
Will
Note: I am running in IE 6.
Here's my Javascript code:
var n = document.getElementById("PASSWORD_FIELD");
var elm = document.createElement('input');
elm.value = n.value;
elm.size = "11";
elm.type = "text";
elm.name = "PASSWORD_FIELD";
//This next line is what causes the weird behavior...
elm.className = "myStyleClass";
var parent = n.parentNode;
parent.removeChild;
parent.insertBefore(elm,parent.firstChild);
--
I've tried adding a foreground color and a background color to my style like this...
.myStyleClass {font-family:Verdana;font-size:10pt;color:FF0000;background-color:#6666CC;}
But the problem seems to happen no matter how I style this. The only way to avoid it that I can see, is to not set a style to the className attribute. But I'd like to be able to set a style.
I can't understand why this is happening or how to fix it. Any ideas or thoughts?
Thanks,
Will