[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() {
//open the form (Here I have to concat the selected option next to the controller's function)
$attributes = array('name' => 'menu_form');
$data = form_open('main/view/'.$selection.'/1', $attributes);
//get the data to fill the dropdown
$result = $this->gramaticas_model->getGramNomes();
foreach($result as $row) $options[$row->id] = $row->titulo;
$selected_option = (empty($_POST['Gramáticas'])) ? '' : $_POST['Gramáticas'];
$js = 'onChange="document.menu_form.submit();"';
$data .= form_dropdown('Gramáticas', $options, $selected_option, $js);
$data .= form_close();
return $data;
}
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.