![]() |
Send value from view to method and vice versa - 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: Send value from view to method and vice versa (/showthread.php?tid=62959) |
Send value from view to method and vice versa - vertisan - 09-11-2015 Hi! I need send value from view to function in controller and return to view. Example on code: VIEW: PHP Code: echo 'Count: ' . AddNumber(2); CONTROLLER: PHP Code: function AddNumber($value) { RE: Send value from view to method and vice versa - davicotico - 09-11-2015 (09-11-2015, 12:57 PM)vertisan Wrote: Hi! In this case a helper function is the best choice. RE: Send value from view to method and vice versa - casa - 09-12-2015 Hi, If you want to send a value to your controller, you are many ways switch your problem. Here, we don't know if you want t send a vlue when you click on a button (picture, etc.) or when a time is elapsed, etc.. A controller is to manage your wiew and call models. If you don't need to do that and simply modify a value without using models, a simply helper or library is sufficient. RE: Send value from view to method and vice versa - Wouter60 - 09-12-2015 I think you need AJAX to do this. Insert a link to the latest Jquery library in the 'head' section of your view (or template). Jquery makes life a lot easier when it comes to implementing AJAX. At the bottom of your view, create a script that sends an AJAX-request to the controller (with the current value), and get the new value back. Jquery can replace the old value by the new value on the fly. |