Combining values from multiple forms or POST/GET

I have a flask-rendered page that contains a field ('filter') that is used to narrow down the results of a database query (using SQLAlchemy). The query returns the results in paginated form. The code looks, in principle, approximately like this:

@blueprt.route('/somepage', methods=['GET', 'POST'])
def somepage():

    page = request.values.get('page', 1, type=int)

    filter = request.args.get('filter', '%', type=str)

    form = SomeForm()
    if form.validate_on_submit(): 
        filter =

    if filter:
        query = SomeData.query.filter(
        query = SomeData.query

    page = request.args.get('page', 1, type=int)
    pagination = query.order_by(SomeData.somefield.desc()).paginate(
    result = pagination.items

    return render_template('sometemplate.html',

The question I now have is the following:

To link form submission and page navigation, I put some javascript in the navigation button. For example:

<a href="#" onClick="form_submit_page(6); return false;">6</a>

The javascript function looks as follows:

function form_submit_page(p) {
    $( "#page" ).val(p);
    $( "#page" ).closest("form").find(":submit").click();

So what I do essentially is abuse the filter form to submit the "page" field. This feels like quite a hack and I would prefer a more transparent solution to pull the info from these two sources (pagination, filter form) together.

Any advice?