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
| <body>
<form id="inscription" method="post" action="form.php">
<div class="task-list">
<ul id="cat">
<li><label for="chk1"><input type="checkbox" name="chk1[]" id="chk1" hidden /></label></li>
<?php
$con=mysqli_connect('localhost','root','');
mysqli_select_db ($con,'promo') ;
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT * FROM categorie ";
$result=mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
echo '<li><label for="chk1"><input type="checkbox" name="chk1[]" id="chk1" value="'.$row[0].'">'.$row[0].'<img id="'.$row[1].'" class="delete-button" width="10px" src="images/close.svg" /></label></li>';
}
mysqli_free_result($result);
mysqli_close($con);
?>
</ul>
</div>
<div id="nestedform">
<input type="text" class ="add-new-task" name="new-task" placeholder="Add a new item..." "/>
<div id="output"></div>
</div>
<input type="button" id="form-button-submit" value="Valider">
</form>
</div>
</body>
<script>
function resetForm(formid) {
$(':input','#'+formid) .not(':button, :submit, :reset, :hidden') .val('')
.removeAttr('checked') .removeAttr('selected');
}
$(document).ready(function() {
$("#form-button-submit").click(function() {
$.post('submit.php', $("form").serialize(), function(data)
{
resetForm('inscription');
});
return false;
});
$("#cat").click(function(event) {
event.stopPropagation();
var currentId = $(this).attr('id');
});
}
);
</script>
</html> |
Partager