I am quite new to JS and I am facing the following problem.
I have a web site in my machine that I run locally. The little code in HTML is as follows:
<div class="table-responsive">
<h1>Json</h1>
<br/>
<table class="table table-bordered table-striped" id="concept_list">
<tr>
<th>Buttons</th>
<th>Name</th>
<th>color</th>
<th>fingerprint</th>
<th>hits</th>
<th>ENGLISH</th>
<th>FRENCH</th>
<th>GERMAN</th>
</tr>
</table>
</div>
This creates basically the headers of a table.
I want to read JSON files locally in my computer and add data to the table. I use a script as follows
<script >
$(document).ready(function(){
$.getJSON("pvmodule.json", function(data){
var concept_list= '';
$.each(data, function(key, value){
concept_list += '<tr>';
concept_list += '<td>'+"HERE I WANT TO INSERT A TOGGLE BUTTON"+'</td>';
concept_list += '<td>'+value.name+'</td>';
concept_list += '<td>'+value.color+'</td>';
concept_list += '<td>'+value.fingerprint+'</td>';
concept_list += '<td>'+value.hits+'</td>';
concept_list += '<td>'+value.EN+'</td>';
concept_list += '<td>'+value.DE+'</td>';
concept_list += '<td>'+value.FR+'</td>';
concept_list += '</tr>';
});
$('#concept_list').append(concept_list);
});
});
</script>
In the JS code above I want to insert a button in the first cell of the table in every row. (where i wrote "HERE I WANT TO ADD A TOGGLE BUTTON") How do I dynamically add those buttons?
The intention being to add up in a field at the end of the web site all the values of the cells where the toggle buttons were clicked by the user.