![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
alert(newDataProduct.text+' '+newDataProduct.value+' '+newDataProduct.selected); |
#3
| |||
| |||
|
|
function addProduct() { * * *dataProductSelection = document.getElementById('dataProducts'); * * * * * * * * productSelection = document.getElementById('products'); * * * * * * * * action = false; * * * * * * * * for (i=0; i<productSelection.length; i++) { |
|
* * * * * * * * * * if (productSelection[i].selected==true) { |
#4
| |||
| |||
|
|
On 6 Jan., 10:33, Bernhard Brockmann <b.brockm... (AT) flb-essen (DOT) de> wrote: function addProduct() { dataProductSelection = document.getElementById('dataProducts'); productSelection = document.getElementById('products'); action = false; for (i=0; i<productSelection.length; i++) { productSelection.length ????? if (productSelection[i].selected==true) { produktSelection[i] ????????? getElementById liefert doch kein Array. |
#5
| ||||||
| ||||||
|
|
horst lorenz schrieb: On 6 Jan., 10:33, Bernhard Brockmann <b.brockm... (AT) flb-essen (DOT) de> wrote: function addProduct() { dataProductSelection = document.getElementById('dataProducts'); productSelection = document.getElementById('products'); action = false; for (i=0; i<productSelection.length; i++) { |
|
productSelection.length ????? if (productSelection[i].selected==true) { produktSelection[i] ????????? getElementById liefert doch kein Array. [...] getElementById liefert hier ein Objekt vom Typ Select, |
|
welches unter Anderem die Eigenschaft options besitzt. Durch diese Optons kann iterieren, wie durch ein Array wie in meiner Funktion verwendet. |
|
Ich habe meine Frage in der zwschenzeit selbst beantwortet. Die Funktion appendChild funktioniert im IE im Zusammenhang mit dem Objekt vom Typ Option nicht korrekt zusammen. |
|
Deshalb verwende ich nun die Methode add des Objekts Select. Hier muss man aber auch wieder zwischen IE und Anderen unterscheiden. |
|
also dieht die Lösung wie folgt aus: try { productSelection.add(newDataProduct, null); } catch(e) { productSelection.add(newDataProduct); } statt dataProductSelection.appendChild(newDataProduct); nun funktionierts. |
![]() |
| Thread Tools | |
| Display Modes | |
| |