With javascript I want to insert a select with options:
function newRow() {
var tbodyRef = document.getElementById('myTable').getElementsByTagName('tbody')[0];
var lastRow = tbodyRef.rows[tbodyRef.rows.length - 1];
var lastCell = lastRow.cells[lastRow.cells.length - 1];
var newCell = newRow.insertCell();
newCell.innerHTML = '<select name="reportList" method="GET" action="/">'+
'<option value="data">data.value</option>' +
'</select>';
}
At the bottom of my HTML file:
<script>var data = '{{ reportList | tojson }}';</script>
My question is how can I use the reportList list in my javascript as options (in place of data.value). Right now, 'data' variable is a string and not an array, do I have to split it into a string or is there another way?