How to get checkbox value in codeigniter?

Member

by aubrey , in category: PHP Frameworks , 9 months ago

How to get checkbox value in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , 9 months ago

@aubrey 

To get checkbox value in CodeIgniter, you can use the following steps:

  1. In your HTML form, create a checkbox element and assign it a name attribute:
1
<input type="checkbox" name="checkbox_name" value="1">


  1. In your controller method, you can retrieve the checkbox value using the input class provided by CodeIgniter:
1
$checkbox_value = $this->input->post('checkbox_name');


  1. You can now use the $checkbox_value variable to check if the checkbox is checked or not:
1
2
3
4
5
6
7
if($checkbox_value){
    // Checkbox is checked
    echo "Checkbox is checked";
} else {
    // Checkbox is not checked
    echo "Checkbox is not checked";
}


That's it! You have successfully retrieved the checkbox value in CodeIgniter.

Related Threads:

How to get value from another model in codeigniter?
How to get value from url in codeigniter?
How to get value from two table using join in codeigniter?
How to get max and min value of a column from database in codeigniter?
How to get checkbox state in ember.js?
How to get values of checkbox array in laravel?