Reputation: 239
I am trying to dynamically update the value of my button in a gridview to a count value. Now, I get Unclosed String literal error at " out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
My goal is to assign the value of count as the button value. What Am i doing wrong?
<tr>
<td colspan=4 align="center"
style="background-color:teal">
<b>User Record</b></td>
</tr>
<tr style="background-color:lightgrey;">
<td><b>Record Number: </b></td>
<td><b>Card Number: </b></td>
<td><b>MiddleName:</b></td>
<td><b>BankAccountID:</b></td>
<td><b>CurrencyID:</b></td>
<td><b>DayTransactionLimit:</b></td>
<td><b>Select:</b></td>
</tr>
<%
if(request.getParameter("mobilenumber")!=null)
{
FileReader fr = new FileReader(new File(("C:\\Users\\Farheen\\Documents\\NetBeansProjects\\Demo\\records.txt")));
BufferedReader br = new BufferedReader(fr);
String line = null;
int count =0;
// out.println("<table>");
while((line = br.readLine()) != null){
//out.print(line + "<br/>");
out.println("<tr>");
String[] data = line.split("\t");
for (String val : data) {
out.println("<td>" + val + "</td>");
count ++;
}
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
out.println("</tr>" );
}
// out.println("");
br.close();
}
%>
Upvotes: 0
Views: 1530
Reputation: 2924
As I have written in my answer to your other question, do not use Java code to generate HTML output. As you can see, it is very error prone.
Anyway, if you insist, then use
out.println("<td><input type =\"button\" id=\"getid\" onclick=\"getbuttonid()\" value=\"" + count + "\"></td>");
Upvotes: 1
Reputation: 5871
change
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
to
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "+ "<%=count%>" + ">" + "</td>");
Upvotes: 0