jeudi 22 octobre 2015

Can I assign values to a checkbox for checked and unchecked states?

I have a single checkbox in a form which I want to assign values to for both checked and unchecked states. The values are saved in a MySQL database. This is my php to retrieve the values.

<?php
// Value = 10.00
// This should be the checked value (initial state)
function getDel1()
{
global $con;
$get_del1 = "select * from delivery";
$run_del1 = mysqli_query($con, $get_del1);
while($row_del1=mysqli_fetch_array($run_del1)){
$leeds = $row_del1['delivery_leeds'];
echo "$leeds";
}
}
?>

<?php
// Value = 20.00
// This should be the unchecked value (user interaction)
function getDel2()
{
global $con;
$get_del2 = "select * from delivery";
$run_del2 = mysqli_query($con, $get_del2);
while($row_del2=mysqli_fetch_array($run_del2)){
$leeds = $row_del2['delivery_other'];
echo "$other";
}
}
?>

I can display the values independently by calling either function in a div which is adjacent to the form checkbox but I don't know how to assign those values to the form checkbox and then automatically update the div depending on the user interaction. Any suggestions?




Aucun commentaire:

Enregistrer un commentaire