views:

75

answers:

3

I getting any error on a I'm creating in my client side code. The issue seems to be coming from the "onclick" that I'm adding to the row. You can see the function below. Then underneath that is what the "this.clickvalue" actually equals that on the line that is giving me the "unterminated string literal" error.

51 var row = "<tr " + this.clickValue + ">"
52 for(i=0; i<this.count; i++) {
53
54 row += "<td>" + this.values[i] + "</td>";
55
56 }
57 row += "</tr>";
58
59 $(row).appendTo(tbl);


<tr onclick=detailDoc.openDocument('Technical Library')>     //line 51 during walkthorugh

EDIT: Ok so it looks like I need that last line to eventually look like this:

<tr onclick="detailDoc.openDocument('Technical Library')">

So my now is how exactly do I do that. the "this.clickValue" is being created in a webservice and passed back to my JS function. The code looks like this:

string click = "onclick=detailDoc.openDocument('" + result.IPT_Name + "');";

Not sure how to get the quotes to go over with it.

+3  A: 

That last line looks like it should be this:

<tr onclick="detailDoc.openDocument('Technical Library')">

UPDATE

Response to your edit: is that C#?

I suppose your code for generating that should look like this:

string click = "onclick=\"detailDoc.openDocument('" + result.IPT_Name + "');\"";
Drew Wills
Take a look at my edit if you can, because I think you are correct but I'm not sure how to implement
Collin Estes
Thanks Drew that is what I've needed. Not sure how I've made it as long as I have without having the need to put "" in a literal.
Collin Estes
A: 

I'm not sure whether that's already the problem, but you need to quote your onclick event:

<tr onclick="detailDoc.openDocument('Technical Library')"> 
Pekka
A: 

The code is correct, except for 2 things:

  • on line 51, you need to add a semicolon (;) at the end of the line.

  • your onclick attribute needs quotes (all attributes should have quotes

(like this)

<tr onclick="detailDoc.openDocument('Technical Library')">
Gabriel McAdams
It looks like Javascript code to me, so the semicolon shouldn't be necessary.
Mark Byers
@Mark: If only the parser had your eyes. The OP said that the error is on line 51. If that is true, then the semicolon is the problem. If the problem was the quotes on the attribute value, then the error couldn't occur until the code was called (line 59?).
Gabriel McAdams