mercredi 17 juillet 2019

I need to post array with a value from checkbox and unchecked checkbox

i need to post multiple data in array , it will send an id and value from checkbox i need it even when the checkbox is not checked .

i need a value like this when i clicked submit

id checkbox 1 1 2 0 3 1 4 1 5 0 6 1

please anyone help i need this urgently

the output always getting the hidden checkbox even i alr disable it with javascript , so its not what i expected

<?php
// Create database connection using config file
include_once("config.php");
$no=1;
// Fetch all users data from database
$result = mysqli_query($mysqli, "SELECT * FROM MP WHERE JENIS_POTENSI='Linguistik' ");

while($user_data = mysqli_fetch_array($result)) {  
?>
<tr>
<td> <?php echo $no++ ?> </td>
<td> <?php echo $user_data[1] ?> </td>
<td class="actions">
<label class="checkbox-inline">
<input type="checkbox" id="checkbox1" name="setuju[]" value="1" onclick="waha()"> Setuju
<input type="hidden" id="checkbox2" name="setuju[]" value="0"/>
<script>
function waha(){
if(document.getElementById("checkbox1").checked) {
document.getElementById("checkbox2").disabled = true;
}
}
</script>

<input type="text" class="hidden" value="<?php echo $user_data[0] ?>" id="inlineCheckbox1" name="idsoal[]">
</label>
</td>
</tr>
<?php } ?>



Aucun commentaire:

Enregistrer un commentaire