[thelist] quote in variable

Lee Kowalkowski lee.kowalkowski at googlemail.com
Tue May 15 04:20:05 CDT 2007


On 14/05/07, Daniel Kessler <danielk at umd.edu> wrote:
> > var answer = window.confirm("Would you like to delete the publication
> > " + the_publication + "; #" + ticket_num + "?");
>
> > http://www.htmlgoodies.com/beyond/javascript/article.php/3470891
>
> That's great and all, but the reason that I asked is that I don't
> know what text will be in the variable the_publication.  It's user-
> entered, so difficult to escape.
> Is there no function used in this case?

Am I missing something?  You don't need to know what text will be in
the variable in your example.  You're window.confirm statement is
syntactically correct as it is, what your variable contains or where
it came from is irrelevant at this point.

<script>
  var the_publication = "\"I've got a quote in me!\"";
  var ticket_num = 1;
  var answer = window.confirm("Would you like to delete the
publication" + the_publication + "; #" + ticket_num + "?");
</script>


-- 
Lee



More information about the thelist mailing list