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.

Checkboxexlimit errichten

Empfohlene Antworten

Veröffentlicht

Hey,

folgendes Problem: Ich hab 3 Bereiche wo ich Checkboxen habe und ich will ein Limit mit je 3 Boxen haben. Also sobald man die 4te Box anwählt werden die restlichen disabled. Ich hab ein Script zusammengestellt welches weniger gut geworden ist aber immerhin gegangen ist. Beim ersten hat es "wunderbar" geklappt, nur das sich keine anderen Boxen anwählen ließen selbst aus den anderen Teilen der Site ... Selbst wenn ich das Script copy+gepasted mit neuem namen hab, es ging nicht. Vielleicht kann mir jemand da helfen.

Code vom Script, das beim ersten Bereich ging.

function setChecks(obj){

//checkCount

if(obj.checked){

checkCount=checkCount+1

}else{

checkCount=checkCount-1

}

//bei Auswahl der 4ten Box, unchecken dann alert mit Warnung

if (checkCount>maxChecks){

obj.checked=false

checkCount=checkCount-1

alert('Checkboxlimit erreicht')

}

document.getElementById('unternehmen_frauen_weil').disabled = true;

}

				<input type="checkbox" id='unternehmen_frauen_nt' name="zusammenarbeit_nt" value="zusammenarbeit"/>schlechtere Zusammenarbeit<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="leistung_nt" value="leistung"/>schlechtere Leistungen der Mitarbeiter und Mitarbeiterinnen<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="organisation_nt"value="organisation" />aufwändigere Organisation<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="kundenfreundlichkeit_nt"value="kundenfreundlichkeit" />weniger Kundenfreundlichkeit<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="umsatz_nt" value="umsatz"/>niedrigerer Umsatz<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="kosten_nt" value="kosten"/>höhere Kosten<br />

				<input type="checkbox" id='unternehmen_frauen_nt' name="sonstiges_nt" value="sonstiges"/>Sonstiges: <input type="text" id='unternehmen_frauen_wiel' name="unternehmen_frauen_weil" /><br /><br />

			</p>
<p class="optionen">

			<input type="checkbox" name="vorteil_kennenlernen"value="kennenlernen" />persönliches Kennenlernen<br />

			<input type="checkbox" name="vorteil_unternehmen" value="unternehmen"/>Informationen über Unternehmen<br />

			<input type="checkbox" name="vorteil_karriere" value="karriere"/>Informationen über Karrierewege<br />

			<input type="checkbox" name="vorteil_fuehrung" value="fuehrung"/>Informationen über Führungspersönlichkeiten<br />

			<input type="checkbox" name="vorteil_business-netzwerke" value="business_netzwerke"/>Informationen über Business-Netzwerke<br />

			<input type="checkbox" name="vorteil_sonstiges" value="sonstiges"/>Sonstiges: <input type="text" id='vorteil_weil' name="vorteil_weil" /><br />

		</p>

Vielen Dank im vorhinein für deine Hilfe!

Grüße

Adrian :)

gelöst mit:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

  "http://www.w3.org/TR/html4/loose.dtd">


<html>

<head>

<script type="text/javascript">

function checkboxOC(ele, namenRe, limit) {

	var checked = 0;

	var form = ele.form;

	for (var i = 0; i< form.elements.length; i++){

		if (form.elements[i].type == "checkbox" && form.elements[i].checked && namenRe.test(form.elements[i].name)){

			checked++;

		}

	}


	for(var i=0; i<form.elements.length; i++) {

		if(form.elements[i].type == "checkbox" && namenRe.test(form.elements[i].name) && form.elements[i].checked == false) {

			form.elements[i].disabled = (checked >= limit)? true: false;

		}

	}

}

</script>

</head>

<body>

	<form name="form" action="" method="post" id="form1">

		<div>

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_1" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_2" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_3" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_4" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_5" value="1"></div><div>

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_6" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_7" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_8" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^vorteil_/, 3)" name="vorteil_9" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_1" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_2" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_3" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_4" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_5" value="1"></div><div>

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_6" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_7" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_8" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^nachteil_/, 3)" name="nachteil_9" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_1" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_2" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_3" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_4" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_5" value="1"></div><div>

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_6" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_7" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_8" value="1">

		<input type="checkbox" onclick="checkboxOC(this, /^test_/, 3)" name="test_9" value="1">

		<input value="hallo">

		</div>

	</form>

</body>

</html>

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.