everyone, beforehand - I'm a bloody but motivated developer beginner.
I am currently trying to react to simple events (click on a button) in the HTML code in my Django project. Unfortunately without success ...
HTML:
<form>
{% csrf_token %}
<button id="CSVDownload" type="button">CSV Download!</button>
</form>
JavaScript:
<script>
document.addEventListener("DOMContentLoaded", () => {
const CSVDownload = document.querySelector("#CSVDownload")
CSVDownload.addEventListener("click", () => {
console.dir("Test")
})
})
</script>
Do I need JavaScript for this? Or is there a way to react directly to such events in python (Django)?
I am really grateful for all the support.
Since I'm not really "good" yet - a simple solution would be great :)
Python (Django)
if request.method == "POST":
projectName = request.POST["projectName"]
rootDomain = request.POST["rootDomain"]
startURL = request.POST["startURL"]
....
With this, for example, I managed to react to a kind of event, i.e. when the user sends the form. The problem here, however, is - if I have several forms on one page, then I cannot distinguish which function should be carried out: / I am at a loss