I am appending some HTML to an existing table.
as such I am using jquery .append.
this works great. my issue is that I want to post some infotmation to my controller in the form of a variable.
below is my current syntax:
$(tablename).append(
'<tr>'+
'<td><div id="divone" onclick="showdetails('q','+"po"+')">+</div></td>'+
'</tr>'
)
variable q is a variable with a number. lets say 23
. this renders correctly.
variable po is also a variable but a string, lets say so149
when this is appended to the table is appears in HTML as:
<tr>
<td>
<div id="divone" onclick="showdetails(23,so149)">+</div>
</td>
</tr>
on clicking the div, I get the below error in firebug:
ReferenceError: so149is not defined
showdetails(12,so149)
because variable po is a string, it sees it as a variable and not a string. how can i get this value to be passed with the post as a string?
I have tried varios apostophe combinations without luck.
Please advise and thanks as always.
You've got your quotes slightly wrong..
'<td><div id="divone" onclick="showdetails('+q+',\''+po+'\')"...