1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Modal form</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }
h1 { font-size: 1.2em; margin: .6em 0; }
div#users-contain { width: 350px; margin: 20px 0; }
div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
.ui-dialog .ui-state-error { padding: .3em; }
.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<script>
$(function() {
$( "#supprimer-user" )
.button()
.click(function() {
var bValid = true;
if ( bValid ) {
//cete méthode permet dexécuter du code pour toute les checkbox cochées, dans lexemple si une chechbox est cochée, on affiche son id.
// Troisième méthode
$("input[type=checkbox]:checked").each(
function() {
// Insérer son code ici
alert($(this).attr("id"));
var test =($(this).attr("id"));
//document.write(test);
console.log("test");
$.ajax({
type: "POST",
url: "supprimer.php",
data:test,
});
});
}
});
});
</script>
</head>
<body>
<div id="users-contain" class="ui-widget">
<h1>Liste des Stagiaires:</h1>
<table id="users" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Id</th>
<th>Nom</th>
<th>Salaire</th>
</tr>
</thead>
<?php
/*** connexion***/
header('Content-Type: text/html; charset=UTF-8');
try
{
// On se connecte à MySQL : $connection = new PDO( $dns, $utilisateur, $motDePasse );
$connection = new PDO('mysql:host=localhost;dbname=societe','root','');
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$sql = 'SELECT * FROM employe';
try {
$select = $connection->query($sql);
echo'
<script language="javascript">
function cocher(numero)
{
if(document.getElementById(numero).checked){
document.getElementById(numero).checked=false;
}
else{
document.getElementById(numero).checked=true;
}
}
</script>';
$result = $select->setFetchMode(PDO::FETCH_NUM);
while ($row = $select->fetch()) {
echo'<a><tbody><tr>
<td>'.'<input type="checkbox" name="idvaleur[]" id="'; echo $row[0];echo'" value="'; echo $row[0]; echo'"> </form>'.'</td>
<td OnClick="cocher('; echo "'$row[0]'";echo')">'.$row[1].'</td>';
echo'
<td OnClick="cocher('; echo "'$row[0]'";echo')">'.$row[2].'</td>';
echo'
</tr></tbody></a>';
}
echo'</table></div> ';
}
catch (PDOException $e) {
print $e->getMessage();
}
?>
<div class="bouton"><input type="button" id="supprimer-user" value="Suppression " ></div>
</body>
</html> |
Partager