Need to escape parentheses in script parameter string???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KathyB

    Need to escape parentheses in script parameter string???

    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
  • Lasse Reichstein Nielsen

    #2
    Re: Need to escape parentheses in script parameter string???

    KathyBurke40@at tbi.com (KathyB) writes:
    [color=blue]
    > 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."[/color]

    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.
    [color=blue]
    > 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.[/color]

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

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Kathy Burke

      #3
      Re: Need to escape parentheses in script parameter string???

      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(('A nomaly.aspx?' + sType + sIdNo + sText),
      'Anomaly',
      'width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes');
      }

      My parameters:
      WORKS: onclick="Javasc ript:Anomaly('S tep','1','Start up.')"

      DOESN'T WORK: onclick="Javasc ript:Anomaly('S tep','2.3','Fin ally, 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="Javasc ript:Anomaly('S afety','1','Sta tic 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!

      Comment

      • Richard Cornford

        #4
        Re: Need to escape parentheses in script parameter string???

        "Kathy Burke" <kathyburke40@a ttbi.com> wrote in message
        news:3fa0fb2e$0 $196$75868355@n ews.frii.net...
        <snip>[color=blue]
        > function Anomaly(typeIn, idIn,textIn)
        > {
        > var sType = 'type=' &typeIn;
        > var sIdNo = '+idNo=' &idIn;
        > var sText = '+text=' &textIn & "'";[/color]
        <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.


        Comment

        • Kathy Burke

          #5
          Re: Need to escape parentheses in script parameter string???

          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!

          Comment

          • Kathy Burke

            #6
            Re: Need to escape parentheses in script parameter string???

            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!

            Comment

            • Kathy Burke

              #7
              Re: Need to escape parentheses in script parameter string???

              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...yo u sent me in the right direction.

              Kathy

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

              Comment

              Working...