Ergebnis 1 bis 2 von 2
-
18-10-2016, 18:07 #1
Grünschnabel
- registriert
- 18-10-2016
- Beiträge
- 1
Bild abhängig von gewählten option-Feld anzeigen
Hallo,
ich habe folgendes Problem und denke ich muss da mit AJAX ran, habe bisher allerdings mit AJAX noch nicht wirklich etwas zu tun gehabt.
Ich habe ein Formular, bei dem man aus einem Select-Menü diverse Einträge wählen kann. Zu dem gewählten Punkt soll dann quasi live das passende Bild erscheinen. Das Bild wird nicht über das Formular verknüpft, sondern soll über den value-Wert der option erkannt werden, da die Bilder nach einem Schema abgelegt werden.
Das Formular kommt aus einem CMS und greift hier auf die Datenbank zurück.
Mit folgendem Code wird die Select-Liste generiert.
PHP-Code:<select name="<?= $this->name ?>" id="ctrl_<?= $this->id ?>" class="<?= $this->class ?>"<?= $this->getAttributes() ?>>
<?php foreach ($this->getOptions() as $option): ?>
<?php if ($option['type'] == 'group_start'): ?>
<optgroup label="<?= $option['label'] ?>">
<?php endif; ?>
<?php if ($option['type'] == 'option'): ?>
<option value="<?= $option['value'] ?>"<?= $option['selected'] ?>><?= $option['label'] ?></option>
<?php endif; ?>
<?php if ($option['type'] == 'group_end'): ?>
</optgroup>
<?php endif; ?>
<?php endforeach; ?>
</select>
PHP-Code:<img src="/images/<?= $option['value'] ?>.jpg">
Vielleicht kann mir ja jemand helfen, hier eine Lösung zu finden.
Viele Grüße
Markus
-
18-10-2016, 18:21 #2
Foren-Gott
- registriert
- 19-05-2008
- Beiträge
- 5.666
Ähnliche Themen
-
[FRAGE] MULTIPLE-Option bei Select-Feld abfragen
Von TIMS_Ralf im Forum JavaScriptAntworten: 3Letzter Beitrag: 11-05-2014, 18:21 -
leere option-tags in dynamisch erzeugtem select-feld
Von erlprinz im Forum JavaScriptAntworten: 14Letzter Beitrag: 24-10-2010, 23:03 -
Option Feld aus Formular in anderes Feld übertragen
Von pepe im Forum JavaScriptAntworten: 5Letzter Beitrag: 07-08-2008, 15:12 -
input feld/option-select feld abfrage
Von xxoes im Forum JavaScriptAntworten: 3Letzter Beitrag: 26-03-2002, 12:29 -
Verschiedene Texte abhängig von Datum / Tag anzeigen?
Von FUZZI_CCDU im Forum JavaScriptAntworten: 2Letzter Beitrag: 14-10-2001, 20:32
Lesezeichen