How do I retrieve data from database and put the data in a JavaScript array variable?

Ravi Verelly

(Assuming your server supports server-sde JavaScript...) Write server side script to get data from data base. Some thing like this will work:
<script> var a = new Array(); </script> <% int i=0;
ResultSet rs = stmt.executeQuery(sqlQuery);
while (rs.next()) {
i++; %>
<script> a[<%=i%>] = "<%=rs.getString(0)%>"; </script>
<%}rs.close();%>

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact