Hello,
I have a table that is passed via ajax and displayed. When the code is passed, it also passed all the javascript associated with the pass, as the code doesn't seem to work if I just put it in the page that it is being passed to.
When I click a in the table that has been passed, I would like to take the data convert it to a input field. Each TD has a class of table2, so in theory this should be simple.
$(".table2").click(
function () {
var html = $(this).html();
$(this).empty().html('<input name="" type="text" value="' + html + ' " />);
});
But I get a
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /products.php on line 90
When I try to do an ajax call on it.
If I try creating php variables, and passing the form data that way, I get an illegal XML error.
Any ideas?
EDIT
The reason I didn't include the PHP is that it is rather lengthy, and all it is doing is echoing some HTML/JS:
$dbh=mysql_connect ("name","user", "pass") or die('I cannot connect to the database because:'. mysql_error());
echo '<script type="text/javascript" charset="utf-8">
$(".table2").click(
function () {
var html = $(this).html();
$(this).empty().html('<input name="" type="text" value="' + html + ' " />');
});
});
</script>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="table2">data</td>
<td class="table2">data</td>
</tr>
<tr>
<td class="table2">data</td>
<td class="table2">data</td>
</tr>
</table>
';
And it works fine is I replace
$(this).empty().html('<input name="" type="text" value="' + html + ' " />');
With something like alert("you click me!");