V
V
Vitaly Ananiev2021-09-29 20:58:00
Django
Vitaly Ananiev, 2021-09-29 20:58:00

How to link the dropdown list form to the display of information on the site?

How to make a drop-down list like on https://funpay.ru/lots/182/ when you click on the section from the servers, information would be displayed. I'm new to Django and don't know how to implement this? I know how to display information, but how to do it when clicking on a section from the dropdown list?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2021-09-30
@Vitalii181190

In the link example, list filtering is not related to the website backend at all and works locally. You can check this through the Network tab in the Dev Tools of the browser (when you select the option, a request to the server is not sent and the page is not reloaded).
If you want to implement filtering on the server (Django), then in your case you need to listen, for example, to the change event on the select element, and then, depending on the selected option (the value property of the select), send an AJAX (XHR / fetch) request to one of your Django endpoints and process there. Then return the filtered new list and display it on the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question