Send value from view to method and vice versa |
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) {
(09-11-2015, 12:57 PM)vertisan Wrote: Hi! In this case a helper function is the best choice.
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.
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. |
Welcome Guest, Not a member yet? Register Sign In |