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üfung der Radiobuttons per JavaScript

Empfohlene Antworten

Veröffentlicht

Hallo alle, erstmal -> ich bin der Paze =)

Mal mein Quelltext:

<!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 fenster1()

{

var Fneu;

var art=document.Formular.zahlung.value;

Fneu = window.open("","Bestätigung","width=340, height=150");

Fneu.document.open("text/html");

Fneu.document.write(" Sie möchten " + art + " nutzen!");

Fneu.document.close();

}

//-->

</script>

<title>Zahlung</title>

</head>

<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">

<h1>Zahlen</h1>

<br />

<br />

<br />

<form action=""  name="Formular">

  <p>Geben Sie Ihre Zahlungsweise an:</p>

  <p>

    <input type="radio" name="zahlung" value="Mastercard" ID="1"> Mastercard<br />

    <input type="radio" name="zahlung" value="Visa" ID="2"> Visa<br />

    <input type="radio" name="zahlung" value="AmericanExpress" ID="3" > American Express<br />


  </p>

         <input type="button" value="Sags mir"  onclick="fenster1()">


</form>

</body>

</html>

Mein Problem ist, ich möchte per JavaScript den Aktivierten Radiobutton in einem neuen Fester ausgeben.

Der Hacken an der Sache ist, durch den identischen " name="zahlen" " Tag, weiss das JavaScript nicht welcher nun aktiviert ist und gibt mir einfach undefinied an.

Hab schon so einiges versucht, aber egal was ich verwende. Entweder kommt immer "Mastercard" oder eben Undefinied.

Ich hab oft gelesen, es soll mit PHP sehr leicht gehen, aber ich hab absolut keine PHP Kenntnisse, und bin atm auch nicht gewillt es zu lernen.

Ich hoffe hier kann mir villeicht jmd helfen.

Bedanke mich auf jedenfall schon im voraus bei euch =)

Ok, Problemstellung:

Man kann Radiobuttons leider nicht direkt mit Value ansprechen. Daher benötigst du eine Schleife, welche durchläuft und kontrolliert, ob der jeweilige Button gechecked ist.

Hier die Lösung:

<!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 fenster1()

	{

		var Fneu;


		for(x=0;x<3;x++)

			{

				if(document.getElementsByName('zahlung')[x].checked == true)

					{

						var art=document.getElementsByName('zahlung')[x].value;

					}

			}

		Fneu = window.open("","Bestätigung","width=340, height=150");

		Fneu.document.open("text/html");

		Fneu.document.write(" Sie möchten " + art + " nutzen!");

		Fneu.document.close();

	}

//-->

</script>

<title>Zahlung</title>

</head>

<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">

<h1>Zahlen</h1>

<br />

<br />

<br />

<form action=""  name="Formular">

  <p>Geben Sie Ihre Zahlungsweise an:</p>

  <p>

    <input type="radio" name="zahlung" value="Mastercard" ID="1"> Mastercard<br />

    <input type="radio" name="zahlung" value="Visa" ID="2"> Visa<br />

    <input type="radio" name="zahlung" value="AmericanExpress" ID="3" > American Express<br />


  </p>

         <input type="button" value="Sags mir"  onclick="fenster1()">


</form>

</body>

</html>

<hier stand mist>

Danke dir, für den Quellcode, funktioniert bis jetzt ganz gut =)

Bearbeitet von Paze

Kein Ding. Bedenke bitte, dass wenn du neue radio-Buttons hinzufügst auch die Schleife anpasst ;)

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.