I’m trying to declare a String in Javascript which spans multiple lines. The lines consist of HTML and some JSP.
Here is a sample of my code:
function doSth() {
var longString = ["<table>"
,"<tr>"
,"<td>"
,"<select name=dropdownList size=1>",
,"<option value="0" selected>- Select Cake -</option>",
<%
for (int i=0; i<cakes.size(); i++) {
String cake = cakes.get(i).toString();
String selectedCake = "";
%>
"<option value='<%=cakes.get(i)%>' <%=selectedCake%> > <%=cakes.get(i+1)%></option>",
<%
}
%>
,"</select>"
,"</td>"
,"</tr>"
].join("");
}
Eclipse says there is a syntax error, but I am not able to pinpoint the error.
Edit: Sorry I changed the sample code to better reflect my situation.
Could it be that this string has unescaped double-quotes in it?:
Try changing it to:
or even better: