4
I am trying to perform a sort of records on a page by firing a List/Menu, but by firing the same I am losing values of variables from a first selection.
When entering the products page I already position a $Dep variable and show the result. When trying to make the filter by ASC or DESC the page is reloaded, thus losing the previously done search and does not perform the ordering.
I made some attempts, saved the variables in sessions and test the value of the filter variable:
$dep = $_REQUEST['dep']; $subdep = $_REQUEST['sub']; $_SESSION['dep'] = $dep; $_SESSION['sub'] = $subdep; $filtro = $_POST['filtro']; switch ($filtro) { case 1: $ORDER = " ORDER BY produtos.descricao ASC"; break; case 2: $ORDER = " ORDER BY produtos.descricao DESC"; break; default: $order = " ORDER BY produtos.descricao ASC"; }
When selecting a filter option I am triggering the value of the same for the page products.php and the same is so:
And my List/Menu is like this:
<select name="filtro" id="filtro" onchange="valueselect(this.value);">
function valueselect(filtro) { window.location.href = "produtos.php?filtro="+filtro; }
The site for display is this: Website in Development
If there are several combos ex: parents, city, state it is better to use ajax to avoid refreshing the screen. If only one you do one on
<select>
compare the database items with the request value in this case addselected="selected"
at the time of writing the<option>
– rray
Hello @rray, I’m not using ajax and I believe this is the problem, but I can’t find an example of list/menu with this feature, thanks for the help.
– adventistapr