Insert a textbox into a span
Posted on 2006-11-29
I have a textbox object that I create like this:
var _textbox = document.createElement ("input");
_textbox.setAttribute ('type', 'text');
_textbox.setAttribute ('id', name);
_textbox.value = value;
_textbox.name = name;
Assuming I have a <span> on the page and have already assigned that to an object, what I want to do is insert that textbox into the span, something like this:
_span.innerHTML = _textbox;
Doing the above causes this to display on the page (not a textbox):
I'm aware that use the innerHTML property and "spell out" the HTML (i.e. <input name="somename" ... /> but I imagine that there must be some way to insert the object, and have it render the HTML for me, that's what I'm looking for.
Any help would be appreciated.