Reputation: 5646
i am new to java script and i need some help with following code sample.
basically i want to know how can i access the values in the following array
$('#sheet').sheet({
title: "${title}",
buildSheet: true,
workbook: "${sheet}"
});
this workbook : "${sheet}" contains 2d array.
actually i have forloop to print workbook : ${sheet}
content
<c:forEach var="sheet" items="${workbook}">
<table>
<c:forEach var="row" items="${sheet}">
<tr>
<c:forEach var="cell" items="${row}">
<td>test test</td>
</c:forEach>
</tr>
</c:forEach>
</table>
</c:forEach>
basically i want to loop through values inside workbook
variable
i really appreciate any help with that. thanks for looking into this
Upvotes: 0
Views: 1947
Reputation: 61550
The 2D array is actually a JavaScript object, which function similar to a dictionary or map in other programming languages. You can get the values by passing the keys into the object.
example:
myObject = { 'key' : 'value' }
//get the value
var myValue = myObject['key'];
alert(myValue);
Upvotes: 0
Reputation: 26
Take a look at jquery.each()
$.each(your2darray, function(key, value) {
alert('key : ' + key + 'value:' + value);
}
http://api.jquery.com/jQuery.each/
Upvotes: 1