HTML href - how to not rewrite GET parametrs

48 views Asked by At

I'm developing a webpage and I ran into little trubble.

There is a list of users where I need to paginate by ?page=5, but also I need to search. But I can't figure how to set href to do from users/list?search=test&ST=on&PA=on&TE=on -> users/list?search=test&ST=on&PA=on&TE=on&page=5 Can somebody helps me? Thanks, before.


CODE:

my pagination looks like:

<li>
  <a href="?page={{ pagination.next_page_number }}" aria-label="Next">
    <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
  </a>
</li>

And my search form:

`

<form class="form-inline" method="GET" action="">
  <div class="form-group">
    <div class="input-group">
      <input type="text" class="form-control" placeholder="Search for..." id="search" name="search" value="{{ search }}">
      <span class="input-group-btn">
        <button type="submit" class="btn btn-default">Go!</button>
      </span>
    </div>
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox" id="ST" name="ST" {% if ST %}checked{% endif %}> Students
    </label>
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox" id="PA" name="PA" {% if PA %}checked{% endif %}> Parents
    </label>
  </div>
  ...
  <button type="submit" class="btn btn-default">Search</button>
</form>

`

1

There are 1 answers

0
kojow7 On BEST ANSWER

Yes, that is the way to do it. Usually it is good to rank the variables in order of importance. So I might move the page variable to the beginning as follows, but either way works:

users/list?page=5&search=test&ST=on&PA=on&TE=on