onChange(..) what's wrong?

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

    #1

    onChange(..) what's wrong?

    Hi,

    In the next sentence, what's wrong?

    <select name='id' onChange="windo w.location='deP aso.jsp?vuelta= a&nombre=id&ant erior=ejecutivo
    = 'Daniel Perez'&valor='+ this.options[this.selectedIn dex].value">

    IE complains about missing ";"

    TIA
  • RobG

    #2
    Re: onChange(..) what's wrong?

    Omar wrote:[color=blue]
    > Hi,
    >
    > In the next sentence, what's wrong?
    >
    > <select name='id' onChange="windo w.location='deP aso.jsp?vuelta= a&nombre=id&ant erior=ejecutivo
    > = 'Daniel Perez'&valor='+ this.options[this.selectedIn dex].value">[/color]

    Try:

    <select name='id' onChange="
    window.location =encodeURI(
    'dePaso.jsp?vue lta=a&nombre=id &' +
    'anterior=ejecu tivo=' +
    'Daniel Perez' +
    '&valor=' +
    this.options[this.selectedIn dex].value);
    ">




    --
    Rob

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: onChange(..) what's wrong?

      Omar wrote:
      [color=blue]
      > In the next sentence, what's wrong?
      >
      > <select name='id'
      >[/color]
      onChange="windo w.location='deP aso.jsp?vuelta= a&nombre=id&ant erior=ejecutivo
      ^-- Here the JS string starts ...[color=blue]
      > = 'Daniel Perez'&valor='+ this.options[this.selectedIn dex].value">[/color]
      ^----.
      .... and here it ends. Since `Daniel' is not a valid reference,
      the script engine yields a runtime (syntax) error:
      [color=blue]
      > IE complains about missing ";"[/color]

      If you use ' as string delimiter, escape 's within it with \'
      Note that you cannot escape attribute value delimiters within
      attribute values this way which imposes a limitation upon the
      nesting level of string literals.


      PointedEars
      --
      Bill Gates isn't the devil -- Satan made sure hell
      _worked_ before he opened it to the damned ...

      Comment

      • Richard Cornford

        #4
        Re: onChange(..) what's wrong?

        Thomas 'PointedEars' Lahn wrote:[color=blue]
        > Omar wrote:
        >[color=green]
        >> In the next sentence, what's wrong?
        >>
        >> <select name='id'
        >>[/color]
        >[/color]
        onChange="windo w.location='deP aso.jsp?vuelta= a&nombre=id&ant erior=ejecut
        ivo[color=blue]
        > ^-- Here the JS string starts ...[color=green]
        >> = 'Daniel Perez'&valor='+ this.options[this.selectedIn dex].value">[/color]
        > ^----.
        > ... and here it ends. Since `Daniel' is not a valid reference,
        > the script engine yields a runtime (syntax) error:[/color]

        Syntax errors (as this is) are generated when the script source code is
        interpreted, before it is executed (and source with syntax errors
        doesn't get executed), and so they are not runtime errors.
        [color=blue][color=green]
        >> IE complains about missing ";"[/color]
        >
        > If you use ' as string delimiter, escape 's within it with \'
        > Note that you cannot escape attribute value delimiters within
        > attribute values this way which imposes a limitation upon the
        > nesting level of string literals.[/color]

        Hex and Unicode escape sequences may be used within ECMAScript string
        literals, so the delimiters used for attribute values do not need to be
        an issue.

        Richard.


        Comment

        Working...