Solved

Passing quotes to a function in javascript

Posted on 2008-10-08
3
720 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 32

Expert Comment

by:Big Monty
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now