Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
JavaScript and PT
bagman
I have the following code attempting to take a value from my DCR and pass it to a JavaScript function.
<td width="170"><a href=").$promoitem[2].q(" target="_blank" onclick="return(openwin(').$promoitem[2].q('))"><b class="articleheader">).$promoitem[1].q(</b></a></td>
The call to $promoitem[2] in the href section works fine. But, the second call (openwin function) gets quoted exactly in the generated page as shown below...
<td width="170"><a href="/us/customer/whichcompany.html" target="_blank" onclick="return(openwin(').$promoitem[2].q('))"><b class="articleheader">Not sure which company to contact?</b></a></td>
Is there a way to escape the single quotes or something?
I'm using the latest versions of TS and TST.
Find more posts tagged with
Comments
Adam Stoller
I'm not sure about javascript - but you could try using backslashes to escape internal double-quotes ("...\"...\"..."), if you're within Perl context you could use the qq() subroutine - which is like putting double-quotes around everything without the actual double-quotes. Or perhaps you can do variable substitution earlier and put the entire javscript piece of code for the onclick into a variable which you can then output with one level of quotes instead of multiple nested quotes?
Just guessing here - since I'm not sure I understand the code you posted.
--fish
(Interwoven Senior Technical Consultant)
bagman
I moved the substitution to another variable and put the new variable inside the onclick event and everything worked out fine. Thanks for the tip.