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.

Javascript: Wert Optionfeld --> Inputfeld

Empfohlene Antworten

Veröffentlicht

Moin,

scheinbar hab ich heut nen Knoten im Kopf.. Jedenfalls komm ich nicht auf den Fehler :(

Ich habe ein Formular, bestehend aus einem Input Feld und einem Dropdownfeld.

Nun will ich per OnChance() im Dropdownfeld, den Wert des Input Feldes ändern, aber irgendwie will das nicht. Bekomme aber auch keine Javascript Fehlermeldung :(

Irgendjemand eine Idee?

Formular:


	<form name="ACForm" action="index.php" method=POST">

		<input type="text" size="3" maxlength="2" name="intAuftrag">

		<select size="1" name="Auftrag" onChange="updateACForm("Auftrag")>"

			<option> Auftrag 1 </option>

			<option> Auftrag 2 </option>

			<option> Auftrag 3 </option>

			<option> Auftrag 4 </option>

		</select>

		<input type="submit" value="Speichern">

Javascript:

function updateACForm(strACPart) {

	var myindex  = document.ACForm.Auftrag.selectedIndex

	var SelValue = document.ACForm.options[myindex].value

        document.ACForm.intAuftrag.value = SelValue

}

Kann da jemand mal auf den Knoten einhauen?

Danke und Gruss

dgr

Edit:

Die Übergabe des strACPart erfolgt nur, weil ich das hinterher mit derselben Funktion für mehrere Inputfelder machen muss. Habe ich hier nur gekürzt, da die Auswahl des richtigen Quell- und Zielfeldes für das eigentlich problem keine Rolle spielt..


<select size="1" name="Auftrag" onChange="updateACForm("Auftrag")>"

Da hauen die Anführungszeichen nicht hin - gleich zweimal.
<select size="1" name="Auftrag" onChange="updateACForm('Auftrag')">

  • Autor

*grmbl*

Da hätte man nu echt selbst drauf kommen können :(

Danke :)


function updateACForm(strACPart) {

	if (strACPart == "Auftrag") {

		var myIndex  = document.ACForm.Auftrag.selectedIndex;

		alert(myIndex);

		var SelValue = document.ACForm.options[myIndex].value;

	}

}

Aufruf wie oben per Onchange.. Allerdings gibt mir das Alert momentan noch ein Undefined aus.. *grübel*

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.