Today I hit an error and discovered that in IE the .type of an input element is read-only!

In IE the .type of an input element cannot be set dynamically; input.type="hidden"; in IE an input cannot be dynamically switched between text and hidden;

Problem description:

There’s a chunk of js like this: together with this chunk of html: What nickname do your parents call you? What’s the name of your best friend? Who is the teacher you respect most? Custom question
What I wanted to do: let the user pick an item from the dropdown; if the last item “Custom question” is selected, make the text box visible and give it focus; if any other item is selected, hide the text box and set its value to the text of the selected item. In FF this works fine, but in IE you can’t set safeQuestion.type="text".

Cause:

In FF, input element .type [ = sType ] is supported; in IE the input.type property is read-only. Official statement: In IE, except for elements created dynamically with the createElement method, the type property is read-only in all other cases

Solution:

Just switch to controlling visibility with Style…

What nickname do your parents call you? What’s the name of your best friend? Who is the teacher you respect most? Custom question