Reputation: 33
Radio button gets unchecked after I switch to next page using pagination. After switching when I come back to previous pages it gets unchecked. I want that it should hold the value or it should be checked.
I am new to Codeigniter.
Upvotes: 2
Views: 309
Reputation: 2993
After submitting form you can put the value of checkbox in session and after coming back to previous page you can retrieve it from session and make it checked.
Set Radio button value in session
$this->session->set_userdata('name',value);
Retrieve value from session and make checkbox checked.
<?php
$checked_value = $this->session->userdata('name');
?>
<input type="checkbox" value="1" <?= ($checked_value == 1) ? 'checked="checked"' :'' ?> />
Implement this in your code.
Upvotes: 0