Je cherche un moyen d'afficher après un click, deux boutons radios. J'y arrive déja mais en plaçant bien ces boutons grâce à une manipulation CSS d'un div(id="radio"). Malheureusement j'ai plusieurs lignes à mon tableau, et j'aimerai plutôt que de rentrer manuellement la position de chaque bloc de boutons(radio) qu'ils apparaissent directement en dessous de l'image sur laquelle je viens de cliquer.
Voici le code :
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
</head>
<body>
<table>
<tr>
<td>Matri.</td>
<td>Actif</td>
<td>Nom</td>
<td>Prenom</td>
<td>Qualification</td>
</tr>
<tr>
<td>0</td>
<td>OUI</td>
<td>DUBEDAT</td>
<td>Bastien</td>
<td align="center"><img src="settings.png" width="20" heigth="20" a href="" onclick="javascript:visibilite('radio'); return false;" ></a>
<div id="radio" style="display:none;">
<form method="post">
<input type="radio" name="radio" value="etam" onchange="submit(this.form)"/><span>Etam</span><br />
<input type="radio" name="radio" value="ouvrier" onchange="submit(this.form)"/><span>Ouvrier</span></br>
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$commande_valide = true; // Valeur de départ
if($commande_valide) {
if(isset($_POST['radio'])) {
try {
$db = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$req = $db->prepare('UPDATE jeux_video SET nom = :nvnom where id = 1');
$req->execute(array(
'nvnom' => $_POST['radio'],
));
}
catch(Exception $e) {
echo 'Une erreur est survenue !';
die();
}
}
}
} else
echo "Aucune qualification !\n";
?>
</div></td>
</tr>
</table>
<script type="text/javascript">
function visibilite(thingId) {
var targetElement;
targetElement = document.getElementById(thingId) ;
if (targetElement.style.display == "none") {
targetElement.style.display = "" ;
} else {
targetElement.style.display = "none" ;
}
}
</script>
</body>