![]() |
refresh page with dropdown - 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: refresh page with dropdown (/showthread.php?tid=11041) |
refresh page with dropdown - El Forum - 08-23-2008 [eluser]tfncruz[/eluser] Hi! I have a main menu inside a drop-down field. Anybody knows how to refresh the page every time the user selects a new menu item? Thanks! refresh page with dropdown - El Forum - 08-23-2008 [eluser]Rick Jolly[/eluser] Code: <form name="menu_form" action="your_controller/your_method" method="post"> refresh page with dropdown - El Forum - 08-23-2008 [eluser]tfncruz[/eluser] Sorry, I'm not getting it... I have the following function: Code: private function getGramMenu() { Now... every time the user selects a new item, I want to refresh the page depending on the selection chosen. Could you explain how I may accomplish this? refresh page with dropdown - El Forum - 08-23-2008 [eluser]Rick Jolly[/eluser] See the additions below: [quote author="tfncruz" date="1219534614"]Sorry, I'm not getting it... I have the following function: Code: private function getGramMenu() { Now... every time the user selects a new item, I want to refresh the page depending on the selection chosen. Could you explain how I may accomplish this?[/quote] Make sure to filter/validate the $_POST variable. Edit: I now see that you have a $selection variable for your form action. I was assuming that you'd always submit to the same page and load content based on the menu. However, you can change the form action dynamically as well. Instead of calling "document.menu_form.submit(); in the select tag, call a javascript function that changes the form action before it submits. refresh page with dropdown - El Forum - 08-23-2008 [eluser]tfncruz[/eluser] Thanks Rick! I tried that and the browser refreshes every time I make a new selection. But the following errors are occurring: First, "Undefined variable: selection". I think I can initialize this var with the third uri segment. Then, when I select a option and the browser refreshes, it returns the following error "Disallowed Key Characters". I already tried to remove the accents from "Gramática" but that doesn't solve the issue... Suggestions...? refresh page with dropdown - El Forum - 08-23-2008 [eluser]tfncruz[/eluser] Solved! Thank you very much Rick! The solution to refresh the page is in the js. Then the solution was to point the form to a function that redirects to the view function with the required parameters. here's the code: Code: private function getGramMenu($gramID) { Now I only have to check, if $this->input->post('gramaticas') is set, redirect to 'main/view/lalala'. If not, redirect lalala. Thank you again! |