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.

Überprüfen von Optionsfeld

Empfohlene Antworten

Veröffentlicht

Hallo.

Ich habe in einem Formular folgendes Problem:

Anrede []Herr[]Frau

Dabei benutze ich Optionsfelder die den gleichen Namen haben.

<div class="text11">Anrede: *</div>

				<div class="frau"><input type="radio" name="Anrede" value="Frau">Frau</div>

				<div class="herr"><input type="radio" name="Anrede" value="Herr">Herr</div>

Zum Überprüfen, ob ein Feld gesetzt ist rufe ich bei SUBMIT des Formulars folgende Funktion auf:
	function chkFormular()

{

	 if(document.Formular.Anrede.value =="")

	  {alert("Bitte wählen Sie eine Anrede aus!");

	  document.Formular.Anrede.focus();

	  }

}

Mit Textfeldern habe ich mit dieser Weise keine Probleme aber beim Optionsfeld klappt das nicht.

Kann mir da jemand sagen, woran dies liegt?

Vielen Dank schonmal

Mit Textfeldern habe ich mit dieser Weise keine Probleme aber beim Optionsfeld klappt das nicht.

verwende die eigenschaft .checked anstelle von .value; weiters musst du bei mehreren gleich benamsten radios - also quasi einer "optionsgruppe" - das ganze als array behandeln.

function getCheckedValue(radioObj) {

	if(!radioObj)

		return "";

	var radioLength = radioObj.length;

	if(radioLength == undefined)

		if(radioObj.checked)

			return radioObj.value;

		else

			return "";

	for(var i = 0; i < radioLength; i++) {

		if(radioObj[i].checked) {

			return radioObj[i].value;

		}

	}

	return "";

}

s'Amstel

Konnte es anders lösen.

Danke dennoch.

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.