By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Need to escape parentheses in script parameter string???

P: n/a
Hi, I'm passing a parameter to a script, which sometimes fails.
However, I discovered that the ones failing had parentheses within the
text string, e.g., "Step: Press the (0) on the console."

I've learned how to escape apostrophes, but how do I do so for parens?
Is it \( ? Also, where ' was the xml entity for apostrophe,
would someone know the one for left and right parens? Can't find that
either...not having much luck today with my searches.

Thanks! Kathy
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Ka**********@attbi.com (KathyB) writes:
Hi, I'm passing a parameter to a script, which sometimes fails.
However, I discovered that the ones failing had parentheses within the
text string, e.g., "Step: Press the (0) on the console."
Parentheses have no special meaning in either Javascript strings or
HTML. I.e., the failure is not due to the parentheses in the string literal,
but due to the way the string is later operated on.
I've learned how to escape apostrophes, but how do I do so for parens?
Is it \( ? Also, where ' was the xml entity for apostrophe,
would someone know the one for left and right parens? Can't find that
either...not having much luck today with my searches.


No need for it. Show us the code that breaks instead.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
Thanks, Lasse,

By DOESN'T WORK, I mean the new window does not open.

My script:

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' &typeIn;
var sIdNo = '+idNo=' &idIn;
var sText = '+text=' &textIn & "'";

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly',
'width=650,height=700,left=100,toolbar=no,menubar= no,resizable=yes');
}

My parameters:
WORKS: onclick="javascript:Anomaly('Step','1','Startup.') "

DOESN'T WORK: onclick="javascript:Anomaly('Step','2.3','Finally, press
the (Menu) button located
above the (Recipe) button.')"

But oddly enough (for me at least), the following used to work, but now
doesn't:

onclick="javascript:Anomaly('Safety','1','Static prevention straps and
lab coats must be worn at all
times.')"

Your help is greatly appreciated!

Thanks,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

P: n/a
"Kathy Burke" <ka**********@attbi.com> wrote in message
news:3f*********************@news.frii.net...
<snip>
function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' &typeIn;
var sIdNo = '+idNo=' &idIn;
var sText = '+text=' &textIn & "'";

<snip>

You are getting confused between server side language and client side.
The - & - operator in JavaScript is the bitwise AND operator not string
concatenation (+) and in a URL query string the - & - is used to
separate name-value pairs within the query string not the - + - symbol.
I would expect the above to be more like:-

var sType = 'type=' + typeIn;
var sIdNo = '&idNo=' + idIn;
var sText = '&text=' + textIn + "'";

Though I expect that concatenating - "'" - to the final line is also a
mistake.

Richard.
Jul 20 '05 #4

P: n/a
Richard, I make that change (thanks for explaining) but get the exact
same results as my previous posting.

Any other thoughts?

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

P: n/a
I've discovered WHY it is breaking, but don't know HOW to fix it!

I'm generating my html via xml/xsl. The lines that don't work are those
that end up on two different lines in html source. No hard returns etc,
but when I delete the space that puts the script back on one
line...works fine.

PLEASE can anyone tell me how to fix this?

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #6

P: n/a
I've discovered that the authoring tool being used to create the xml
files was set to be 72 character lines in the output files. Changed that
and all is well.

Thanks for responding...you sent me in the right direction.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.