Solved

Passing quotes to a function in javascript

Posted on 2008-10-08
3
762 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

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.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

752 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