in reply to Perl, JavaScript and quoting/escaping
You can also use a heredoc:
print <<HTML; <a href="" onclick="this.element.insert( "<tr id="someid"> <td> <a href="" onclick="this.function.test('')"> </a> </td> </tr>') "> HTML
This also allows you to make the code readable (as I hope I've done), and therefore identify and fix any mis-matched tags and quotes.
However, in this example you're using double quotes for the call to insert, then you're also using double quotes for the name of the tr element. That can only lead to heartbreak .. you'll either have to use less quotes or escape some of them. I think the following should work:
print <<HTML; <a href="" onclick=this.element.insert( "<tr id=someid> <td> <a href='' onclick=this.function.test('')> </a> </td> </tr>")> HTML
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl, JavaScript and quoting/escaping
by ikegami (Patriarch) on Sep 23, 2008 at 20:57 UTC |