How to clear 2 form fields with 1 hx-target Django

I have a form to select counterparty, object and section

When im choosing counterparty which have object and this objects has section all`s good But when i change counterparty which have object and doesnt have sections i still has sections from previous object

I want to clear with hx-target 2 fields: object and sections, but its working only with one How am i suppose to do that?

counter.html

<div class="mt-3">
    {{ form.contractor_counter.label_tag }}
    {% render_field form.contractor_counter class='form-select mt-2' autocomplete='off' hx-get='/objects/' hx-target='#id_contractor_object' %}
</div>

<div class="mt-3">
    {{ form.contractor_object.label_tag }}
    {% render_field form.contractor_object class='form-select mt-2' autocomplete='off' hx-get='/sections/' hx-target='#id_contractor_section' %}
</div>

<div class="mt-3">
    {{ form.contractor_section.label_tag }}
    {% render_field form.contractor_section class='form-select mt-2' autocomplete='off' %}
</div>

my_form

Back to Top