Hallo,
ist es möglich innerhalb einer foreach-Schleife bestimmte <option></option> auf disabled setzen solange der Wert bei $freigabe nicht auf 1 steht?
Der PHP dazu schaut so aus
Das ganze sieht dann so aus
Bildschirmfoto 2019-09-13 um 16.23.28.png
die letzten 6 dürfen nicht angeklickt werden, solange bestellt/bestätigt nicht geklickt wurde.
ist es möglich innerhalb einer foreach-Schleife bestimmte <option></option> auf disabled setzen solange der Wert bei $freigabe nicht auf 1 steht?
PHP-Code:
<form action="" method="POST">
<select name="projekt_status" id="projekt_status" onchange="if (this.value) { this.form.submit(); }" <?php if ($erlaubeBestellung == 0): ?>disabled="true" <?php endif ?> >
<option value="">-- Bitte wählen --</option>
<?php $statusAusgabe = status($mysqli);
foreach($statusAusgabe as $array){ ?>
<option value="<?php echo $array['code'];?>"<?php echo ($projekt_status == $array['code'] ? "selected" : "");?>><?php echo $array['titel'];?></option>
<?php } ?>
</select>
</form>
PHP-Code:
function status($mysqli) {
$stmt = $mysqli->prepare("SELECT id, code, titel, sort, farbe, class FROM status ORDER by sort ASC ");
$stmt->execute();
$stmt->bind_result($id, $ode, $titel, $sort, $farbe, $class);
$stmt->store_result();
if($stmt->num_rows() > 0) {
while ($stmt->fetch()){
$status[] = array(
'id' => $id,
'code' => $code,
'titel' => $titel,
'sort' => $sort,
'farbe' => $farbe,
'class' => $class
);
}
return $status;
}
}
Bildschirmfoto 2019-09-13 um 16.23.28.png
die letzten 6 dürfen nicht angeklickt werden, solange bestellt/bestätigt nicht geklickt wurde.
Kommentar