Dashboard > WebWork > ... > FAQ > How can I put a String literal in a Javascript call, for instance in an onChange attribute
  WebWork Log In View a printable version of the current page.  
  How can I put a String literal in a Javascript call, for instance in an onChange attribute
Added by Onyeje Bose, last edited by Onyeje Bose on Nov 05, 2005
Labels: 
(None)

The problem is in escaping quotes and getting the 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):

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

Notice here that there are single quotes surrounding the double quotes, and then the single quotes inline in the Javascript are escaped. This produces this result:

onchange="someFunc(this.form, 'abc')"

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators