I am trying to get the value of some input field in my django template, the form is in a loop
e.g {% for p in prediction %} {% endfor %}
.
I have this simple line to grab the id from the input field let odds = document.getElementById("odds").value
Based on the fact that i have all these function in a django loop, am i not supposed to get all the odds when i console.log(odds)
{% for p in prediction.prediction_data.all %}
<form action="#" method="POST">
<input type="text" value="{{ p.odds }}" id="odds">
<input type="number" value="" name="amount" id="amount" onkeyup="CalculateNewBalance()">
<script>
function CalculateNewBalance(){
let odds = document.getElementById("odds").value
let stake_amount_input = document.getElementById("amount")
console.log(odds);
</script>
</form>
{% endfor %}
[![enter image description here][1]][1]