?
Solved

Escape Character Help: onclick='myFunction(1,"+iParseThisString+")'

Posted on 2006-05-18
5
Medium Priority
?
328 Views
Last Modified: 2008-03-10
Hello,
If you know about how to use escape character, I think it should be very easy for you to help me.
I need to parse string variable within single quotes like this:

var iParseThisString = "Hello";
document.write ("<table><tr><td onclick='myFunction(1,"+iParseThisString+")'>Link</td></tr></table>");

THE PROBLEM IS: iParseThisString as a string cannot be parsed.
Error is "Hello is not defined"
Character \ must be used, but how?..................

Thanks.
0
Comment
Question by:Vadymus
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16712733
I would go with:

document.write ("<table><tr><td onclick=\"myFunction(1,'"+iParseThisString+"')\">Link</td></tr></table>");

-r-
0
 

Author Comment

by:Vadymus
ID: 16712979
Unfortunately, that did not work for me.
To be more precise, this is my code:

var iParseThisString = "Hello";
var iParseThisNum = 553;

array("<table><tr><td onclick='myFunction("+iParseThisNum+","+iParseThisString+",1)'>Link</td></tr></table>");

Note: iParseThisNum works well because it is a number, but iParseThisString does not
Thank you for your help.
0
 

Author Comment

by:Vadymus
ID: 16713005
Also, it works well if I write the string as it is without variable:

array("<table><tr><td onclick='myFunction("+iParseThisNum+",\"Hello\",1)'>Link</td></tr></table>");

But how to make that "Hello" be a string variable instead?
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 80 total points
ID: 16713018
array("<table><tr><td onclick='myFunction("+iParseThisNum+",\""+iParseThisString+"\",1)'>Link</td></tr></table>");

-r-
0
 

Author Comment

by:Vadymus
ID: 16713072
marvelous!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

864 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