5568 sujets
Sémantique web et HTML
<label class="form-check-label" style="font-weight:bold;">Style de mosaïque :</label><br>
<div class="form-check">
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st1" value="st1" checked/>
<label class="form-check-label" style="font-weight:normal;" for="st1">Artistique</label><br>
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st2" value="st2"/>
<label class="form-check-label" style="font-weight:normal;" for="st2">Moderne</label><br>
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st3" value="st3"/>
<label class="form-check-label" style="font-weight:normal;" for="st3">Mélange</label><br>
</div><br>
Et le Php :
if(isset($_POST["submit"])) {
$mosaicStyle ="1";
if (isset($_POST['GroupMosaicstyle']))
{
switch ($_POST['GroupMosaicstyle'])
{
case 'st1':
$mosaicStyle = "1";
break;
case 'st2':
$mosaicStyle = "2";
break;
case 'st3':
$mosaicStyle = "3";
break;
default:
$mosaicStyle = "1";
break;
}
}
<div class="form-check">
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st1" value="st1" checked/>
<label class="form-check-label" style="font-weight:normal;" for="st1">Artistique</label><br>
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st2" value="st2"/>
<label class="form-check-label" style="font-weight:normal;" for="st2">Moderne</label><br>
<input class="form-check-input" type="radio" name="GroupMosaicstyle" style="font-weight:normal;"id="st3" value="st3"/>
<label class="form-check-label" style="font-weight:normal;" for="st3">Mélange</label><br>
</div><br>
Et le Php :
if(isset($_POST["submit"])) {
$mosaicStyle ="1";
if (isset($_POST['GroupMosaicstyle']))
{
switch ($_POST['GroupMosaicstyle'])
{
case 'st1':
$mosaicStyle = "1";
break;
case 'st2':
$mosaicStyle = "2";
break;
case 'st3':
$mosaicStyle = "3";
break;
default:
$mosaicStyle = "1";
break;
}
}
Merci de rééditer ton dernier message afin de te conformer aux règles d'édition d'un post
Modifié par niuxe (04 Aug 2021 - 22:33)
<?php
if(!empty($_POST['GroupMosaicstyle'])){
$mosaicStyle = $_POST['GroupMosaicstyle'];
}
$data = [
'Artistique',
'Moderne',
'Mélange',
];
?>
<p>Style de mosaïque :</p>
<div class="form-check">
<?php foreach($data as $k => $v): ?>
<div class="input radio">
<input class="form-check-input" type="radio" name="GroupMosaicstyle" id="st<?= $k ?>" value="<?= $k + 1 ?>" <?= $k == 0? 'checked' : ''?> />
<label class="form-check-label" for="st<?= $k ?>"><?= $v ?></label>
</div>
<?php endforeach; ?>
</div>
Modifié par niuxe (04 Aug 2021 - 22:33)