onChange(..) what's wrong?

O

Omar

Hi,

In the next sentence, what's wrong?

<select name='id' onChange="window.location='dePaso.jsp?vuelta=a&nombre=id&anterior=ejecutivo
= 'Daniel Perez'&valor='+this.options[this.selectedIndex].value">

IE complains about missing ";"

TIA
 
R

RobG

Omar said:
Hi,

In the next sentence, what's wrong?

<select name='id' onChange="window.location='dePaso.jsp?vuelta=a&nombre=id&anterior=ejecutivo
= 'Daniel Perez'&valor='+this.options[this.selectedIndex].value">

Try:

<select name='id' onChange="
window.location=encodeURI(
'dePaso.jsp?vuelta=a&nombre=id&' +
'anterior=ejecutivo=' +
'Daniel Perez' +
'&valor=' +
this.options[this.selectedIndex].value);
">
 
T

Thomas 'PointedEars' Lahn

Omar said:
In the next sentence, what's wrong?

<select name='id'
onChange="window.location='dePaso.jsp?vuelta=a&nombre=id&anterior=ejecutivo
^-- Here the JS string starts ...
= 'Daniel Perez'&valor='+this.options[this.selectedIndex].value">
^----.
.... and here it ends. Since `Daniel' is not a valid reference,
the script engine yields a runtime (syntax) error:
IE complains about missing ";"

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
 
R

Richard Cornford

Thomas said:
Omar said:
In the next sentence, what's wrong?

<select name='id'
onChange="window.location='dePaso.jsp?vuelta=a&nombre=id&anterior=ejecut
ivo
^-- Here the JS string starts ...
= 'Daniel Perez'&valor='+this.options[this.selectedIndex].value">
^----.
... and here it ends. Since `Daniel' is not a valid reference,
the script engine yields a runtime (syntax) error:

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.
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top