jeudi 20 août 2015

How to make check box as checked while webpage load by default in codeigniter MVC

Html code:

<input type="checkbox" id="my_data"  name="my_data" value="1" <?php echo($my_data == 1 ? 'checked' : ''); ?>/>

Controller code:

$my_data_val = isset($_POST['my_data']) && $_POST['my_data'] ? "1" : "0";

$data["my_data"] = $my_data_val;

i want checked the check box by default while page loading.

Error result : check box value 0 or unchecked while page loading.

Aucun commentaire:

Enregistrer un commentaire