Im trying to display multiple charts.
Right now, I have <canvas id="pie-chart">
inside a loop and document.getElementById("pie-chart")
will only return the first element with that id. How do I create a dynamically html attribute?
<table class="table">
<tr>
<th>
Questions
</th>
</tr>
@foreach (var question in (List<Testv3.Models.MyViewModel>)ViewData["questionlist"])
{
<tr>
<td>
@question.Question
<br />
<div class="chart">
<canvas id="pie-chart"></canvas>
</div>
</td>
</tr>
}
</table>
A part of my script section:
var ctx1 = document.getElementById("pie-chart").getContext("2d");