Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem on IE for onBlur 1

Status
Not open for further replies.

richardko

Programmer
Joined
Jun 20, 2006
Messages
127
Location
US
Hi,
I am creating a text box in a form and trying to use the onBlur event but the onBlur event doesnt seem to execute in IE. It executes nicely in Firefox. I looked at the microsoft documentation for onBlur and it said to use tab-index property but even then this doesnt work. Any idea? I am using the code below to create the text box.
thanks
rko

function createTextBox(name) {
var textElem = document.createElement("input");
textElem.setAttribute("type", "text");
textElem.setAttribute("name", name);
textElem.setAttribute("id", name);
if (name == (skuName + nextRow)) {
textElem.setAttribute("TABINDEX", "0");
textElem.setAttribute("onBlur", "chkmessage('heeello')");
}
return textElem;
}
 
[tt]
if (name == (skuName + nextRow)) {
if (window.attachEvent) {
textElem.attachEvent("onblur", function() {chkmessage('heeello')});
} else if (window.addEventListener) {
textElem.addEventListener("blur", function() {chkmessage('heeello')},true);
}
}
[/tt]
 
hi, thanks for the reply. Your code worked on the IE perfectly. I tried to implement another onBlur function but it did not work as well...i am catching a null exception both in firefox and IE. am i doing something wrong in the code below?

if (name == (skuName + nextRow)) {
if (window.attachEvent) {
textElem.attachEvent("onblur", "submitForm('" + name + "')");
}else if (window.addEventListener) {
textElem.addEventListener("blur", "submitForm('" + name + "')",true);
}
}
 
You can do it simply like this.
[tt]
if (name == (skuName + nextRow)) {
if (window.attachEvent) {
textElem.attachEvent("onblur", function(){submitForm(name)});
} else if (window.addEventListener) {
textElem.addEventListener("blur", function(){submitForm(name)},true);
}
}
[/tt]
 
Thanks a lot, that helped.
ko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top