Learner
Learner

Reputation: 33

Radio button should be checked after switching to next page in Codeigniter

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

Answers (1)

Alex Mac
Alex Mac

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

Related Questions