Question

I have this function defined in my in my JSP:

function addcolor(){
    alert("found " + document.getElementById("clrCd").value);
}

my HTML (from struts 1.3 app)

<input type="text" name="clrCd" maxlength="2" size="2" value="">
<input type="button" name="add" value="ADD" onclick="addcolor()">

when my browser is in quirks mode, and I click the ADD button, I get the alert with the value of the text input

if I put my browser into IE8 standards mode (via F12 console) and run the same code, I get:

Error: Unable to get value of the property 'value': object is null or undefined

why on earth is this happening....I've lost an entire day to dealing with IE and all it's bullshit.

this is a legacy app and I can't really change much, but I'd really like to get them off quirks mode so we can start using some HTML5 features like bootstrap and angularJS.

any ideas?

Jason

Was it helpful?

Solution

This isn't "IE bullshit", it's that you don't have an element with any id clrCd. You've only set the name attribute.

Add an id="clrCd" to your element, and you will have more luck.

OTHER TIPS

Actually You can do this before IE7 See document

http://msdn.microsoft.com/en-us/library/ie/ms536437(v=vs.85).aspx

Windows Internet Explorer 8 and later. In IE8 Standards mode, getElementById performs a case-sensitive match on the ID attribute only. In IE7 Standards mode and previous modes, this method performs a case-insensitive match on both the ID and NAME attributes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top