I have a form with a <select>
with several options in it to choose the order in which the information that the user sees on the screen will be displayed:
<form method="get" action="busqueda.php" class="height-30 float-right ">
<select id="orden" name="orden">
<option value="1">Hora: publicación más reciente</option>
<option value="2">Precio: más bajo primero</option>
<option value="3">Precio: más alto primero</option>
<option value="4">Distancia: más cercano primero</option>
<option value="5">Relevancia</option>
<option value="6">Urgentes</option>
</select>
</form>
Selecting an option executes the following:
$('body').on('change', '#orden', function(){
$(this).parents('form').submit();
});
When the user selects the option, for example, Price: lowest first the search is updated and displayed correctly in order.
What happens is that when the page is reloaded the first option that appears in the <select>
is the first Time: most recent publication so if the user would like to see the information with this order I could not select it because the jQuery code only makes submit
when the value of <select>
changes.
How could I do so that once a value was selected, when I reloaded the page, I would show it as the first option in <select>
and thus be able to choose the other options?
I attach images to detail the problem:
I would like this to be shown:
I hope you have explained me well