Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Proper way to escape " in Javascript
Old 06-16-2011, 05:53 PM Proper way to escape " in Javascript
Skilled Talker

Posts: 87
Trades: 0
Code:
<span class="smodal" onclick="displayEditNotesModal('1', 'Notes notes notes\'s. \'\'\'\'\'\' \" \"', 'finaidnotes');"="">	<img src="img/edit.png" alt="Edit Notes" title="Edit Notes" class="icon-action"></span>
This code will not run because of the \" \" inside the parameters of the function. How do I pass this string
Code:
Notes notes notes's. '''''' " "
to this function correctly? I tried addslashes() in php, which gave me the output above.

Thanks so much in advance.
__________________

Please login or register to view this content. Registration is FREE
- The most comprehensive online resource for students and educators.
yuechen is offline
Reply With Quote
View Public Profile Visit yuechen's homepage!
 
 
Register now for full access!
Old 06-17-2011, 09:15 AM Re: Proper way to escape " in Javascript
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Is it that escaping doesn't work in strings enclosed in single quotes. Use double quotes and escape any enclosed double quotes with the backslash.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 06-17-2011, 12:13 PM Re: Proper way to escape " in Javascript
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I'm pretty sure you'll have to write the quotes as their html code, &quot;. So, your example would have to be

Code:
<span class="smodal" onclick="displayEditNotesModal('1', 'Notes notes notes\'s. \'\'\'\'\'\' &quote; &quote;', 'finaidnotes');"><img src="img/edit.png" alt="Edit Notes" title="Edit Notes" class="icon-action"></span>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 06-17-2011, 03:46 PM Re: Proper way to escape " in Javascript
Skilled Talker

Posts: 87
Trades: 0
I've used htmlentities() on all the data (which is something I should've done anyway). Thanks so much!
__________________

Please login or register to view this content. Registration is FREE
- The most comprehensive online resource for students and educators.
yuechen is offline
Reply With Quote
View Public Profile Visit yuechen's homepage!
 
Reply     « Reply to Proper way to escape " in Javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.88981 seconds with 12 queries