Solved

Passing quotes to a function in javascript

Posted on 2008-10-08
3
753 Views
Last Modified: 2013-11-19
I am new at javascript.

I'm wanting to pass numeric and text variables to a function that has 7 parameters.  One of these parameters is generally a fairly verbose piece of text that can contain apostrophes and quotes.

It appears as though when I use onclick=, I need to surround the infomration in quotes.  that's fine except in my largest parameter there is need for many quotes.  In the example shown I've used "xxx" for quotes and then my function replaces "xxx" with quotes. However, I'd rather be able to pass regualr quotes or something more identifiable as quotes so that other users can use this function.

The idea of this code is to allow user to click on an image and the onclick event fires a function that opens a popup.


<a href="#" onclick="return false" style="text-decoration: none">
<img src="images/bw_palms_drop_mini.jpg" width="158" height="105"
alt="bw_palms_drop_mini.jpg" border="0" onclick="picwin2(450,550, 'Car Unveiling Party', 'Car Unveiling Party', '../images/bw_palms_drop.jpg',
          	'$1,200', 
          	'This xxxnew year\'s eve partyxxx was actually staged in October at the car dealership for a xxxNew Model Yearxxx unveiling.  Palm trees with lights ' + 
          	'($350 each) and a classic balloon drop made this party elegantly festive.  At xxxmidnightxxx (okay, 8:30 pm), we had a balloon drop, confetti launch ' + 
          	'and unveiled the xxxNew Modelxxx car!')"></a>

Open in new window

0
Comment
Question by:tjeffryes
3 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 22671878
i BELIEVE you can just double up the double quotes:

onclick="picwin2(450,550, 'Car Unveiling Party', 'Car Unveiling Party', '../images/bw_palms_drop.jpg',
                '$1,200',
                'This ""new year\'s eve party"" .....')
0
 
LVL 1

Author Comment

by:tjeffryes
ID: 22672054
Big Daddy:

This did not work.  Thanks for trying.  

I'm attaching a simpler version of what I'm trying to try and remove the complexity.  I've tried using href="javascript:picwin2()" and onclick="picwin2()" and the results are the same.

I did find the sending &quot works.  That's nice to know and may be the only solution.  however, I'd love to be able to write text in "english" so it would be easy for a non-programmer to use the function.


<a href="javascript:picwin2(450,700,	'Exploding Balloon Tower', 'Exploding Balloon Tower', '../images/column_exploder.jpg', '$200','here is text that has "quotes" in it')"><img src="images/column_exploder_mini.jpg" width="116" height="181"alt="column_exploder_mini.jpg" border="0"></a>

Open in new window

0
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 500 total points
ID: 22672335
Try using &quot;

<a href="javascript:picwin2(450,700,    'Exploding Balloon Tower', 'Exploding Balloon Tower',
'../images/column_exploder.jpg', '$200','here is text that has &quot;quotes&quot; in it')"><img
src="images/column_exploder_mini.jpg" width="116" height="181"alt="column_exploder_mini.jpg" border="0"></a>
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question