Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment:

Update formatting

The problem is Using String literals in Javascript calls requires care in escaping quotes and getting the but leaving double quotes around the final value, like we expect in HTML attributes.

Here's an example of the right way to do this (thanks to John Brad):

Code Block
titleSource
onchange='"someFunc(this.form, \'abc\')"'

Notice here that there are

  • single quotes

...

  • surround the double quotes, and

...

  • inline single quotes

...

  • in the Javascript are escaped

...

  • .

When rendered, the statement is rendered without the pair of surrounding single quotes, and the literal String stays quoted.

code
Code Block
titleOutput
onchange="someFunc(this.form, 'abc')"