Javascript innerHTML being wierd

Associate
Joined
18 Oct 2002
Posts
1,312
Location
Milton Keynes
Hey all

Am using javascript to write a form maker form script, and I have encountered some random problems.

I am using javascript to populate divs with html for forms, and for certain tags (so far select, option, and textarea) they ignore the closing tags that I put in the code.

For textarea this is making anything after the opening textarea tag appear INSIDE the textarea which is not what I want. marc2003 helped me out with the select / option tag issue here, and I have tried the same solution but no joy

Also I noticed if I stick some random characters in the tag, ie :
Code:
<textarea rows="10" cols="30" name="asdasd" id="id_field1" lalala>
It tries doing something with it and turns it into an attribute without my say so!
Code:
<textarea rows="10" cols="30" name="asdasd" id="id_field1" lalala="">

Any ideas?
 
using the same method as before....

Code:
var text = 'blah blah';
document.getElementById('id_1').innerhtml = '<textarea rows="10" cols="30" name="asdasd" id="id_field1">' + text + '</textarea>';
 
Back
Top Bottom