You know, just a couple of minutes ago, we decided not to support that browser. That was just one of the quirks of the browser. There's many more (regular expressions for instance). I want to thank you for following up on this. It's REALLY very nice of you.
Ok, after I add the row to the table, I do:
alert(document.forms[0].my_name);
which generates precisely this: "undefined".
FF and everything else work fine. No errors.
What I do in the code is create a select element and then populate it from an array. It's the populate stage where I get the error -- I get something like "undefined" whenever I try to access it.
Yes, the table is inside a form. It works in all browsers but the Mac IE.
elem.name doesn't do it. What's interesting is that when I do alert(myRow.innerHTML), everything looks fine. The element has the right name attribute. Here's the output of the alert:
<TD><SELECT name=my_name...
Hello,
I've got this pesky problem with the IE under Mac (5.1). Here's the code.
var myTable = document.getElementById("tableID").getElementsByTagName("tbody")[0];
var myRow = document.createElement('TR');
var myTD = document.createElement('TD');
var elem = document.createElement('select')...
Hmm, take a look at the article below. Would be curious about your thoughts.
http://www.easy-reader.net/archives/2005/09/02/death-to-bad-dom-implementations/
So how do I do it across browsers without sniffing?
In IE it's: elem = createElement("<select name='my_name'>")
In FF: elem = createElement('select'); elem.name = 'my_name'
In Safari: elem = createElement('select'); elem.setAttribute('name', 'my_name');
Safari doesn't error back on elem.name =...
Sorry, it did work when I created a simple case. Something within my more complicated case is messing it up, but I'll figure it out. Thanks A LOT for the tip!!!
Here's a thread I found that sort of discusses what I'm talking about: http://www.codingforums.com/archive/index.php?t-10479.html
A related question to my previous posts is: if "if (event)" in a function that doesn't have "event" defined produces "event undefined", then how come checking for...
Yep, I know that window.event is IE only. See, I think, the problem with your version of the function is that if it's assigned within a form like so: "<INPUT type="button" onclick="enterPressed(event)">, it will work in IE because after a series of lookups in the scope chain, it will eventually...
Hello,
here's a function that I have a question about:
function enterPressed(e) {
var charCode;
if (window.event) {
charCode = event.keyCode;
}
else {
charCode = e.which;
}
// alert(charCode);
if (charCode == 13) {
return true;
}
else {
return false;
}
}...
Yep, you're absolutely right. That's what I ended up doing. I tried to play with attachEvent (IE only) and addEventListener (everything but IE) and onclick worked best.
Thank you!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.