By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,688 Members | 1,900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,688 IT Pros & Developers. It's quick & easy.

Java Script and Double Quotes

P: 4
Dear Forum,

First, thanks for reading my Post. So basically I have a Java Script program. To add more to the Data base I can not use " Double Quotes inside the string. How do I work around this irritant and where to I locate the fix. I have done some research about quote blocker script and the use of /" /". But where to exactly place the fix I am unsure..


Thanks, Louis





Thanks, Louis
Oct 16 '07 #1
Share this Question
Share on Google+
8 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Louis. Welcome to TSDN!

I'm going to go ahead and move this thread to the JavaScript forum, where our resident Experts will be better able to help you out.
Oct 16 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Can you show some code which demonstrates the problem?

If the double quotes are within double quotes, you'll need to escape them:
Expand|Select|Wrap|Line Numbers
  1. "a double quote \" "
Oct 16 '07 #3

P: 4
Can you show some code which demonstrates the problem?

If the double quotes are within double quotes, you'll need to escape them:
Expand|Select|Wrap|Line Numbers
  1. "a double quote \" "




Expand|Select|Wrap|Line Numbers
  1. <script language="javascript"> <!--
  2. //          ligHTCC's Joke Generator  
  3. // copy as you like. But please try to find
  4. // some better jokes (or quotes, or ???'s)
  5. //
  6. //NOTE: each joke is one long string of words with no 
  7. //      linefeeds and enclosed in "-s (There may be no "-s 
  8. //      inside the string)
  9.  

Explain: Would I do the command above only once or each time..?
Would you explain where this would go in the script?


Thanks a lot , Louis
Oct 16 '07 #4

acoder
Expert Mod 15k+
P: 16,027
Can you show more of the code? For example, some strings and how they are used in the code?
Oct 16 '07 #5

P: 4
Expand|Select|Wrap|Line Numbers
  1. ligHTCC21="My girlfriend told me I should be more affectionate. So I got a second girlfriend.";
  2.  
  3.  
  4. nrOfLines = 69; // total number of jokes.
  5.  
  6. nr = Math.round(0.5+(Math.random()*nrOfLines));
  7.  
  8. self.document.write(eval('ligHTCC'+nr));
  9.  
  10. function dummy() {};
  11.  
  12. function reload() {};
  13.  
  14. // --> </script>
Oct 16 '07 #6

acoder
Expert Mod 15k+
P: 16,027
Please use code tags when posting code:
[CODE=javascript]
Your JavaScript code here..
[/code]

As an example, see this:
Expand|Select|Wrap|Line Numbers
  1. "My \"girlfriend\" told me..."
Wherever you need to use double quotes within double quotes, escape them in this manner. Alternatively, use single within double and vice versa.
Oct 16 '07 #7

P: 4
acoder,



Thanks..... I appreciate it very much. !!!



Louis
Oct 16 '07 #8

acoder
Expert Mod 15k+
P: 16,027
No problem, you're welcome.
Oct 17 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.