I want to print element of array from Flask on javascript in HTML.
Here is my javascript code in HTML.
<script type="text/javascript">
var a=1;
var test_array = new Array(1000);
var i=0;
{% for info in results %}
test_array[i]={{ info[2] }};
i+=1;
{% endfor %}
</script>
<script>
document.write(a);
document.write(test_array[2]);
</script>
'results' is a variable that receives a value from Flask, and the value is stored in 'test_array'.
I want print element of 'test_array'.
But it isn't print and is it really stored?
What can I do?
I would appreciate your advice.
info[2]? If it's string you have to add quotes liketest_array[i]="{{ info[2] }}";(and surelly escape possibles quotes in value)