如何在单个jsp页面中使用javascript函数访问jsp数组?
String[] abc[]={"saab","volvo","bmw","Benz","Porsche","Jaguar"}; abc[0]="saab";
<% String[] abc={'saab',' volvo',"bmw","Benz","Porsche","Jaguar"}; %> <script language="JavaScript"> var jsArr = new Array(); <% for (int i=0; i < abc.length; i++) { %> jsArr[<%= i %>] = '<%=abc[i] %>'; //Here is the latest update check it sravan .Put single quotes. <%}%> </script> function myFunction() { var select = document.getElementById("dropDownId"); for ( var i = 0; i < jsArr.length; i++ ){ var option = document.createElement("option"); // set the text that displays for the option option.innerHTML = status[i]; // add the option to your select dropdown select.appendChild(option); }