I have been trying to make the value of an integerfield show up as a dropdown list with numbers ranging from 1 to the valueof the integer field for example 47 , the numbers between 1 and 47 will show up as a dropdown menu. i managed to get this code working:
HTML PAGE that's resposible for fetching the integerfield ID since i am displaying it in another model as a foreignkey, this is where i am also trying to make the dropdown list of numbers show up
{% for i in rayons %}
<option id="empla"value="{{ i.pk }}">{{ i.Nombre_des_Emplacments }}</option>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
var n = {{ i.Nombre_des_Emplacments }};
for (var i = 0; i < n+1; i++) {
//creates option tag
jQuery('<option/>', {
value: i,
html: i
}).appendTo('#empla');
}
</script>
{% endfor %}
Result :
note that the Num field is what i am talking about and it's dependent on the previous field so when something other than A1 is selected the Num field will change

i want the numbers to show up as selectable options vertically on top of each other like a normal dropdown menu
Try this one
{% for i in rayons %}
<select id = "empla">
</select>
<!-- <option id="empla"value="{{ i.pk }}">{{ i.Nombre_des_Emplacments }}</option> -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
var n = {{ i.Nombre_des_Emplacments }};
var empla = document.getElementById("empla")
for (var i = 0; i < n+1; i++) {
//creates option tag
empla.options.add(new Option(i,i));
}
</script>
{% endfor %}