0
<div class="col-3 filters">
    <form method="GET" class="filter-form">
        <section class="product-filter__categories">
            <div class="filters__field">
                 <input type="checkbox" id="...category" name="category">
                 <input type="checkbox" id="...category" name="category">
                 <input type="checkbox" id="...category" name="category">
                 <input type="checkbox" id="...category" name="category">
            </div>

I have a lot of inputs and I need to submit the filter form after a user opened (firstly) the page.

I did that:

document.onload = function() {
    form.submit();
}

But after that, form was submited each second. It happens because after the form submiting, page reloads and window loads again and form'll submited again..
How i can solve that?

Hahan't
  • 481
  • 1
  • 4
  • 11
  • Can you explain further why you need to submit automatically on page load? Rather than submit, you might want to consider an ajax request. – lurker Jun 01 '20 at 11:02
  • Checkboxes that an user selected keeps always. When an user open filter form I need submit the form for the GET request like localhost:8000/filter?category=1&category=3&category=5 – Hahan't Jun 01 '20 at 13:01
  • I'm sorry, I don't see how submitting the form when the page loads would keep checkbox settings from the user. I'm not understanding the scenario. Perhaps describe step by step in your question (edit the question). – lurker Jun 01 '20 at 22:26

0 Answers0