473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Syntax problem ?

296 100+
My JS for mouse over is as below -->

Expand|Select|Wrap|Line Numbers
  1. onmouseover="this.T_ABOVE=false;this.T_DELAY=750;return escape('Comment: <TMPL_VAR NAME="Comment">')"
The problem is inside the escape.

Whenever the value of <TMPL_VAR NAME="Comment"> has single quotes the JS doesn't work.
Its because of the single quotes inside escape.

Please tell me what to do.
Feb 28 '07 #1
8 1110
acoder
16,027 Expert Mod 8TB
Actually, do you not think it might be the double quotes instead? They are within double quotes. Escape the quotes using backslash (\), e.g.
Expand|Select|Wrap|Line Numbers
  1. return escape('Comment: <TMPL_VAR NAME=\"Comment\">')
Feb 28 '07 #2
pankajit09
296 100+
Actually, do you not think it might be the double quotes instead? They are within double quotes. Escape the quotes using backslash (\), e.g.
Expand|Select|Wrap|Line Numbers
  1. return escape('Comment: <TMPL_VAR NAME=\"Comment\">')
Thats not the problem.
Just remove the double quotes from the template variable and then solve the problem.
Feb 28 '07 #3
acoder
16,027 Expert Mod 8TB
Post the rest of your code or explain what you are attempting to do with that escape function.
Feb 28 '07 #4
acoder
16,027 Expert Mod 8TB
See this page. In the documentation, it says that single quotes should be escaped and non-alphanumeric characters should be specified using character entities.

So you should use:
Expand|Select|Wrap|Line Numbers
  1. return escape('Comment: &lt;TMPL_VAR NAME=&quot;Comment&quot;&gt;')
Does that solve the problem?
Feb 28 '07 #5
pankajit09
296 100+
See this page. In the documentation, it says that single quotes should be escaped and non-alphanumeric characters should be specified using character entities.

So you should use:
Expand|Select|Wrap|Line Numbers
  1. return escape('Comment: &lt;TMPL_VAR NAME=&quot;Comment&quot;&gt;')
Does that solve the problem?
But that can't be done here because the value is in the template variable .

I got the solution using regular expression in the Perl CGI script.

Is there a solution in the HTML page ?
Feb 28 '07 #6
acoder
16,027 Expert Mod 8TB
But that can't be done here because the value is in the template variable .

I got the solution using regular expression in the Perl CGI script.

Is there a solution in the HTML page ?
I'm not sure what you mean. What is this template variable for? Is it some Perl? Maybe you can post more code so that it makes sense. You are using the script from the walterzorn site?
Feb 28 '07 #7
pankajit09
296 100+
I'm not sure what you mean. What is this template variable for? Is it some Perl? Maybe you can post more code so that it makes sense. You are using the script from the walterzorn site?
The template variable gets value from the Perl CGI script.

I got the solution by using a regular expression in the Perl script.

I wanted to know whether there is a solution in the HTML page where the template variable is present ?
Mar 1 '07 #8
acoder
16,027 Expert Mod 8TB
Oh now I understand your problem. You see, I'm not familiar with Perl.

Well, you should do this on the server-side by escaping the single quotes within the template variable, e.g. Coldfusion has a function JSStringFormat which formats a string for use in javascript. If you have something similar in Perl, use that or write your own.

If you really want to do this on the client-side, set the template variable to a string and escape the single quotes by replacing them with the escaped version, then put that string in the escape function.
Mar 1 '07 #9

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
14
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def...
16
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very...
23
by: Carter Smith | last post by:
http://www.icarusindie.com/Literature/ebooks/ Rather than advocating wasting money on expensive books for beginners, here's my collection of ebooks that have been made freely available on-line...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
4
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this...
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.