dynamically define JavaScript multidimensional arrays with JSTL -


i'm creating multidimensional arrays jstl should be:

[ ['2013-03',22434.0],['2013-04',11234.0],['2013-05',17434.0] ] 

and while doing jstl, white code this:

var arrayz = new array(${list.size()}); <c:foreach var="item" items="${list}" varstatus="s">   arrayz[${s.index}] = new array(["'" + "${item.date}".substring(0,7) + "'", ${item.price}]); </c:foreach> console.log("arrayz: " + arrayz); 

in console turns out :

arrayz: '2013-03',22434.3,'2013-04',11234.1,'2013-05',17425 

how fix it?

your array fine seeing output string, try logging array itself

console.log(arrayz); 

also might suggest simplification of jstl.

var arrayz = [ <c:foreach var="item" items="${list}" varstatus="s">     ["'" + "${item.date}".substring(0,7) + "'", ${item.price}]${!s.last?',':''} </c:foreach> ] 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -