Asp Classic - Keep option select apos post on page

Asked

Viewed 1,489 times

1

Guys, I need some help.

I have the following select HTML Techo

<select id="lstTransacao" name="lstTransacao">
     <option value="null">Todos</option>
     <option value="1">Confirmados</option>
     <option value="0">Não confirmados</option>
</select>

<input id="btnFiltrarTransacao" type="submit" name="btnSearch" value="Filtrar Transações" class="style_button" onclick="javascript: filtraTransacao();">

It’s a page that does a search. It turns out that the page has paging, when I click on the paging button "1", "2", "3", etc. SELECT goes back to the standard "all", I would like to keep in case I click on "Not confirmed" go passing the paging and keep OPTION VALUE="0" for example.

ASP Classic 3.0

Grateful.

2 answers

3


In paging toggle, you need to inform each page the value that was previously selected on <select>. Then you capture the value that was sent on submit and compares in each <option>:

<%lstTransacao = request("lstTransacao")%>

<select id="lstTransacao" name="lstTransacao">
     <option <%if lstTransacao = "null" then%> selected="selected" <%end if%> value="null">Todos</option>
     <option <%if lstTransacao = "1" then%> selected="selected" <%end if%> value="1">Confirmados</option>
     <option <%if lstTransacao = "0" then%> selected="selected" <%end if%> value="0">Não confirmados</option>
</select>

<input id="btnFiltrarTransacao" type="submit" name="btnSearch" value="Filtrar Transações" class="style_button" onclick="javascript: filtraTransacao();">

0

Good morning. A suggestion would be to create a label just take its value in postback and treat the combobox by Jquery...

This a tip can be improved.

 <div id="mydiv" class="0">   
  <select id="lstTransacao" name="lstTransacao" >
   <option value="null">Todos</option>
   <option value="1">Confirmados</option>
   <option value="0">Não confirmados</option>
  </select>
 </div>

$("body").ready(function () {
  if ($('#mydiv').hasClass('0')) {
  $("#lstTransacao").val('0');        
}});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.