I have a small JSON file which looks like this
var myData = [{
"No": 1,
"Ticker": "WSI",
"Units": 72,
"Price In": 15,
"Entry Value": "",
},
{
"No": 2,
"Ticker": "DE",
"Units": 25,
"Price In": 15,
"Entry Value": "",
},
and so on...
Additionally a script that generates a simple table:
var myTable = '<table>';
myTable += '<tr>';
for (var x in myData[0]) {
myTable += '<th>' + x + '</th>';
}
myTable += '</tr>';
for (var i = 0; i < myData.length; i++) {
myTable += '<tr>';
for (var x in myData[i]) {
myTable += '<td>' + myData[i][x] + '</td>';
}
}
myTable += '</table>';
document.getElementById('jstable').innerHTML = myTable;
Two questions:
- How do I proceed with doing various equations on JSON? For Example last column "Entry Value" should return the result of "Units * Price In"
Something like this doesn't work:
var myData = [{
"No": 1,
"Ticker": "WSI",
"Units": 72,
"Price In": 15,
"Entry Value": myData.Units * myData.["Price In"],
},
- As a beginner, what topics should I research in order to be able edit columns after I click on them
Thank you