0

Working on some pretty old code and really stuck on an odd bug. I have a routine that is writing out some controls and I'm getting an InvalidCharacterError thrown from IE.

Here's the code:

var newFileTextControl = "<input type='Text' name='Q" + answer + "P" + partValueCount + "' value='' style='width:80px' id='Q" + answer + "P" + partValueCount + "' />";

and here is what's being written to the browser:

<input type='Text' name='Q22791P1' value='' style='width:80px' id='Q22791P1' />

Here is where I get the error:

var newFileTextDiv = document.createElement(newFileTextControl);

The error doesn't specify what character is causing the problem, hoping someone can see what I can't here. Thanks in advance.

TrevorGoodchild
  • 978
  • 2
  • 23
  • 49

1 Answers1

1

Creating an element that way is kind of an 'old IE trick'...
It appears that IE9 is more strictly following standards.

To be more 'standards-compliant' I would do:

var input = document.createElement("input");
input.setAttribute("type", "text");
...

See also this Q/A...

Hope it helps...

Community
  • 1
  • 1
MarcoS
  • 17,323
  • 24
  • 96
  • 174