Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dropdown per DOM füllen

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe es enflich hinbekommen, per Javascript ein Dropdownmenue erstellen.

Auch erstellt er mir die <option> Tags, allerdings ist das Dropdown Menue leer.

Mit value lege ich zwar einen Wert an, aber ich bekomme den Anzeigewert (der normalerweise zwischen <option>WERT</option> steht nicht rein.

Mit welchem Befehl fülle ich es?

Hier der Code:


function machFeld(frm){

z++;

d=document.createElement('div');

frm.insertBefore(d,document.getElementById('drueber'));

i=document.createElement('input');

ii=document.createElement('input');

iii=document.createElement('select');

iiio1=document.createElement('option');

iiio2=document.createElement('option');

i.name=i.id='input_vorname_t'+z;

ii.name=ii.id='input_nachname_t'+z;

iii.name=iii.id='select_geschlecht_t'+z;

iiio1.name="männlich"

iiio2.text='weiblich'

iiio1.value='m'

iiio2.value='w'


d.appendChild(i);

d.appendChild(ii);

d.appendChild(iii);

iii.appendChild(iiio1);

iii.appendChild(iiio2);

}



Mit foo = document.createElement('option') erzeugst Du nur <option/>

Du musst also an die Option-Nodes noch zusätzlich Text anhängen:

bar = document.createTextNode("myTextNode");

foo.appendChild(bar);

Yepah..

Man dankt! :beagolisc

Kannst du mir auch sagen wie man dem input Field und dem select Field per Javascript ne CSS Klasse zuordnet?

foo.class="Css stile"; ???


  foo.className = 'bar';

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.