Click to See Complete Forum and Search --> : [RESOLVED] innerHTML and form


miob
07-15-2008, 05:01 AM
Hi !

I just figured that if i'm adding <select> menu into innerHTML, it doesn't work in FF, but it's running in IE.

there is HTML tag:

<p id="odstavec_kat"></p>

and i'm trying to add select menu into innerHTML , is that possible ?

sample of code:

document.getElementById("odstavec_kat").innerHTML="\t<select name=\"kategoria\" onchange=\"overhod( this.value)\" style=\"border:1px solid #6699FF; width:174; font-family:Verdana; font-size:8pt; height:17\" size=\"1\"><option selected value=\"53\">ostatné</option></select>";

maybe it should work with document.write, somweone experienced it ?

or must i make it only via form objects ??

m.

Fang
07-15-2008, 05:13 AM
The snippet works, but it is advisable to use the DOM (http://developer.mozilla.org/en/docs/Using_the_W3C_DOM_Level_1_Core)

miob
07-15-2008, 05:57 AM
i know that better would be DOM, but i showed just very small part of code, it would take me a lot of time to remake it to DOM, can you help how to make this working ?

Fang
07-15-2008, 07:06 AM
The snippet works.
If you intend adding input then you must use the DOM.

miob
07-15-2008, 05:20 PM
i have to use <select> not input, is that same case ?

Fang
07-16-2008, 12:32 AM
It's always better to use the DOM instead of innerHTML when adding form elements.

miob
07-16-2008, 03:06 AM
i've found exactly what i was looking for here:
http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm

anyway thanx 4 help