I am trying to build an array of DemoNames.name attribute, dynamically in jsp, how can i create an array and then pass to my js file for further validation?
<c:forEach items="${demoNames}" var="DemoNames">
${DemoNames.name}
</c:forEach>
I am trying to build an array of DemoNames.name attribute, dynamically in jsp, how can i create an array and then pass to my js file for further validation?
<c:forEach items="${demoNames}" var="DemoNames">
${DemoNames.name}
</c:forEach>
You'll want to make this code declaration somewhere in the html after the js file is declared.
<script>
var nameArray = [];
<c:forEach items="${demoNames}" var="DemoNames">
nameArray.push("${DemoNames.name}");
</c:forEach>
yourJSFileFunction( nameArray );
</script>
If you viewed source on this I believe you would have a push line for each of the names.