How to call certain div class when certain condition is done? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to call certain div class when certain condition is done? (/showthread.php?tid=51036) |
How to call certain div class when certain condition is done? - El Forum - 04-18-2012 [eluser]Michal1[/eluser] Hello guys, I have pretty basic and stupid question. How to show certain div class when some condition is done. Let say in my view I have Code: <div class="msg msg-ok"> and in my controller i have function which handles adding articles. Code: public function add_thread() and after this is done I want to display that msg msg-ok from my view. How to do that please? How to call certain div class when certain condition is done? - El Forum - 04-19-2012 [eluser]Michal1[/eluser] Nobody knows? How to call certain div class when certain condition is done? - El Forum - 04-19-2012 [eluser]Silviu[/eluser] I've noticed that you are using a redirect (presumably, after the form was successfully submitted). You can use a flashdata session variable as a hook for that message: Code: public function add_thread() Code: <?if($this->session->flashdata('success')):?> How to call certain div class when certain condition is done? - El Forum - 04-19-2012 [eluser]dhiya[/eluser] Try this solution: in your view: <?php if(isset($message)){ ?> <div class="msg msg-ok"> <p><strong>Your file was uploaded succesifully!</strong></p> <a href="#" class="close">close</a> </div> <?php } ?> in your controller: public function add_thread() { $data = array( 'name' =>$this->input->post('name'), 'text'=>$this->input->post('text') ); if($this->site_model->insert_thread($data)) { $data['message'] = 'your message here'; } $this->load->view('your_view.php',$data); redirect ('site'); } How to call certain div class when certain condition is done? - El Forum - 04-19-2012 [eluser]Michal1[/eluser] thank you so much! How to call certain div class when certain condition is done? - El Forum - 04-19-2012 [eluser]Michal1[/eluser] solved |