This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Checkbox namen aus array geben
#1
Das könnte man so machen

Zitieren
#2
Moin liebes Forum,
auch hier kann man es auch anders machen und deswegen habe ich eine eigene Version gebastelt:

'use strict'; const name1 = ['Gewerk1', 'Gewerk2', 'Gewerk3']; var bod;
document.addEventListener('DOMContentLoaded', () => {
	bod = document.getElementsByTagName('body')[0];
	name1.forEach((element) => {
		let newLabel = document.createElement('label');	newLabel.textContent = element;
		let newCheckBox = document.createElement('input');
		newCheckBox.setAttribute('type', 'checkbox'); newCheckBox.setAttribute('name', element);
		bod.appendChild(newLabel); bod.appendChild(newCheckBox);
	});
});


Gruss scoutrz
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste