Javascript, DOM, textContent, innerHTML, text, IE and FF

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
I've had a right afternoon of it, so I have :(

I've got a couple of questions, and I'll do my best to keep them separate from each other, but I might mess it up!

I've got some problems creating select lists that are cross-browser compatible:

Code:
positionInput = document.createElement('select');
positionInput.appendChild(new Option('pos1',1));

this works wonderfully in Firefox, but IE doesn't like it at all - it just flat-out doesn't populate the 'pos1' part.

I've tried setting it with textContent - only works in Firefox, innerText - only works in IE, text - only works in Firefox, innerHTML - doesn't work reliably in either.

Is there any way I can create the following in IE and Firefox without having to hack about and duplicate stuff a million times?

Code:
<select><option value="1">pos1</option></select>

That was my gripe with SETTING textContent/innerText/whatever - how do I go about universally GETTING it? I assumed that there'd be a function that allowed me to set/get this data, or is that me being a crazed, tree-hugging hippy about everything?

anyone who can help, I'll actually post you a cookie!
 
Back
Top Bottom