Edit my application previously selected item should be viewed? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Edit my application previously selected item should be viewed? (/showthread.php?tid=71649) |
Edit my application previously selected item should be viewed? - kvanaraj - 09-09-2018 I want to my application previously selected items to be displayed accordingly. How to implement this . Controller ******** Code: $data['getcert'] = $this->User_Model->getcert(); ***** Code: $regno = $this->session->userdata('username'); View ***** Code: value="<?php echo (!isset($posted['email'])) ? '' : $posted['email'] ?>" RE: Edit my application previously selected item should be viewed? - InsiteFX - 09-10-2018 Maybe set_value from the form helper. You need to start looking this simple stuff up yourself instead of relying on the forum users. RE: Edit my application previously selected item should be viewed? - ignitedcms - 09-10-2018 I would store the selected values linked to the user's session data, that way you can access their selected choices on any page. Although I'm not entirely sure what you are doing. RE: Edit my application previously selected item should be viewed? - Wouter60 - 09-10-2018 With so little code, it's hard to tell what you actually mean. I guess you want to repopulate the form with previously made choices if the form isn't filled in completely, right? Use the form_validation library. It is well documented on the CI website. There's a function called set_checkbox() in the form helper too. RE: Edit my application previously selected item should be viewed? - kvanaraj - 09-10-2018 (09-10-2018, 07:33 AM)Wouter60 Wrote: With so little code, it's hard to tell what you actually mean. Code: <?php foreach($getcert as $student){ Code: <input type="checkbox" id="mycheck1" name="certid[]" Code: output RE: Edit my application previously selected item should be viewed? - Wouter60 - 09-11-2018 Don't use set_checkbox() to change the value of the checkbox, just it's checked or unchecked status! You really should start reading the documentation!! And once again: it won't work of you give elements the id="mycheck1" in a control structure like foreach { }. If there are 10 checkboxes, they all have the same id. How would that help you to find the right one? So, forget the whole id part. Use a css class to handle the checkboxes through jQuery, and an array name like "certid[]" to return the values of the checked checkboxes to your controller after submitting the form. If you're going to use form_validation, use the "certid[]" reference too, including the square brackets. There are lots of examples for that on the internet. |