Why doesn't parser like this script?

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

    Why doesn't parser like this script?

    Hi, I'm using the following script to pass 3 variables to my next
    form.

    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')
    }

    My parser (msxml4) "thinks" there is a problem with variables sIdNo
    and sText -- the &'s are causing it (expecting a semicolon after
    '&idNo='). It functions but I don't want the user to see the browser
    error...how else to I pass the multiple parameters?

    Any thoughts?

    Thanks, Kathy
  • Lasse Reichstein Nielsen

    #2
    Re: Why doesn't parser like this script?

    KathyBurke40@at tbi.com (KathyB) writes:
    [color=blue]
    > var sType = 'type=' typeIn[/color]

    Do you mean:
    var sType = 'type=' + typeIn

    (and I would add a semicolon at the end, even though it isn't necessary).
    [color=blue]
    > var sIdNo = '&idNo=' idIn
    > var sText = '&text=' textIn[/color]

    Dittos.

    /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

    • Martin Honnen

      #3
      Re: Why doesn't parser like this script?



      KathyB wrote:
      [color=blue]
      > Hi, I'm using the following script to pass 3 variables to my next
      > form.
      >
      > 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')
      > }
      >
      > My parser (msxml4) "thinks" there is a problem with variables sIdNo
      > and sText -- the &'s are causing it (expecting a semicolon after
      > '&idNo='). It functions but I don't want the user to see the browser
      > error...how else to I pass the multiple parameters?
      >
      > Any thoughts?[/color]

      MSXML 4 is an XML parser, if you are using it to parse HTML pages then
      forget about that. If you are trying to author XHTML then you need to
      follow XML rules where you would need to use
      &amp;
      to escape an ampersand. However as you are probably trying to send XHTML
      as text/html to HTML browsers you need another approach, one way is to
      not use inline scripts but only external script files, another way is to use
      <script type="text/javascript">
      //<![CDATA[
      script goes here
      //]]>
      </script>
      that way your page is well-formed XML while being properly handled by
      HTML browsers.
      I (and others) however strongly suggest to use HTML 4.01 instead of
      XHTML 1.0, see for instance


      --

      Martin Honnen


      Comment

      • Stuart Palmer

        #4
        Re: Why doesn't parser like this script?

        It _might_ be because you are missing + in your var calls.

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

        Best way to test is try:-

        function Anomaly(typeIn, idIn,textIn)
        {
        var sType = 'type=' + typeIn;
        var sIdNo = '&idNo=' + idIn;
        var sText = '&text=' + textIn;
        alert('Anomaly. aspx?' + sType + sIdNo + sText);
        }

        This will alert the total url line that is openeing in your popup window.

        Stu

        "KathyB" <KathyBurke40@a ttbi.com> wrote in message
        news:75e8d381.0 310220402.2dd19 ac8@posting.goo gle.com...[color=blue]
        > Hi, I'm using the following script to pass 3 variables to my next
        > form.
        >
        > 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')
        > }
        >
        > My parser (msxml4) "thinks" there is a problem with variables sIdNo
        > and sText -- the &'s are causing it (expecting a semicolon after
        > '&idNo='). It functions but I don't want the user to see the browser
        > error...how else to I pass the multiple parameters?
        >
        > Any thoughts?
        >
        > Thanks, Kathy
        >[/color]


        Comment

        Working...