how to i change variable in view from $data on controller with button |
Help me master.
in my controller Code: public function trending() { in my view Code: <button type="button" name="all"></button> how to i change variable $all to $movie or $tv with button? Quote:how to i change variable $all to $movie or $tv with button? It depends. Is it OK if the page is being reloaded? Then, change your controller function: PHP Code: public function trending($category="all") { Make sure the buttons in your view call the correct url, like: controllername/trending/tv If you don't want a page refresh, then output all data to your view, but hide the "movie" and "tv" tables initially. Use jQuery to toggle between hidden and visible if you click one of the buttons.
(10-04-2018, 05:58 AM)Wouter60 Wrote:Quote:how to i change variable $all to $movie or $tv with button? If i want to use jQuery ajax. what you have referensi for that? or can you give me example?
No, you don't need AJAX.
Code: <button id="show_all">All</button>
(10-04-2018, 08:40 AM)Wouter60 Wrote: No, you don't need AJAX. how to adding active button in this code?
The html button element doesn't have an "active" attribute. I guess you want to add a css class named "active" right?
Example: Code: $('#show_all').click(function(){ |
Welcome Guest, Not a member yet? Register Sign In |