i want to change these values and save these into an array. And afterwards I want to upload it to the Database. And i want to use listener like c# use for example if i select one of them i want to echo the name of that checkbox. Could you help me? Everything works just i cant reach the checkboxes values from javascript or php script. i don't care if javascript or php will be the solution. or do you know how to create checkboxes in javascript?
<?php
require_once('datab.php');
$obj1= new datab();
$db = $obj1->database();
$parancs= 'select * from permissions';
$result = $obj1->quer($res,$db);
$checkbox = null;
$parancs= 'select a.user from datab a, permissions j where a.id = j.id';
$username = $obj1->quer($res,$db);
echo '<pre>';
$id = 0;
$checkbox = null;
foreach($result as $row){
$count = 0;
foreach($row as $rekord)
{
if( $count == 0)
{
echo $username[$id]['user'];
}
else
{
if($rekord == 1)
{
echo $checkbox[$id][$count] = "<input type='checkbox' value='' id='$id|$count' name='checkbox[]' onclick='myfunction()' checked >";
}
else
{
echo $checkbox[$id][$count] = "<input type='checkbox' value='' id='$id|$count' name='checkbox[]' onclick='myfunction()' >";
}
}
$count++;
}
$id++;
echo '<br/>';
}
print_r($checkbox);
file_put_contents('backup.json', json_encode($checkbox));
?>
<!DOCTYPE html>
<html>
<body>
<form method="POST" action="">
<input type="submit" value= "Save" id="submit" name="submit" onclick='myfunction()'>
</form>
</body>
</html>
<script>
//and I'm stucked
</script>
Aucun commentaire:
Enregistrer un commentaire