Implement items filtering

Hi y’all
I have a form in my frontend with <select>, <input type="text"> and a Filter button.
When I select a type of which I want to filter items, wrote a to the input this item value and click Filter button I want to display result to the page.
My backend implementation:

def index(conn, params) do
    page =
      Repo.all(Jobs)
      |> filter_items(params)

    render(conn, "index.html", page: page)
end

def filter_items(jobs, %{"username" => username}) do
    filter_func = fn job ->
      job.user.email == user_email
    end
    filtered_items = Enum.filter(jobs, filter_func)
end

Now I implemented in fronted it this way, is it okay what I do in click listener or is there a better way?

  var button = document.getElementById("filter_jobs_button");
  var jobs_filter_input = document.getElementById("jobs_filter_input")
  var jobs_select = document.getElementById("jobs_select")
 
  
  button.addEventListener("click", () => {
    window.location.href = `/admin/jobs?${jobs_select.value}=${jobs_filter_input.value}`;
  });

Personally I would have just made it a form, doesn’t seem to be a point to use javascript to the the same task. :slight_smile: