PDA

Click to See Complete Forum and Search --> : Quote marks in Javascript string


IClarke
Dec 12th, 2000, 09:05 AM
How do you do this ?? I need to display quote marks (") in an alert box.

Thanks in advance
Ian.

Ianpbaker
Dec 12th, 2000, 09:13 AM
Hi Ian

nice and easy one this just use singel quotes instead

alert('"hello"');

Hope this helps

Ian

IClarke
Dec 12th, 2000, 09:16 AM
Thanks for the reply, problem is i really need the quote marks displayed to be double " quote marks.

Ian.

Dec 12th, 2000, 09:18 AM
You can use a backslash with a single quote or double quote to put them inside a literal in JavaScript. For example:

strExample = 'Programmers write \'Hello World\' programs often.';

or

alert("Programmers write \"Hello World\" often.");

Paul

Ianpbaker
Dec 12th, 2000, 09:19 AM
yeah, that will work. use the sinqle quotes as your string delimiter and then you can put double quotes in side

alert(' jkjkj"jkjkj ');

Sorry, I didn't explain myself properly

Ianpbaker
Dec 12th, 2000, 09:20 AM
or paul's way works as well, he posted without me realising

IClarke
Dec 12th, 2000, 09:21 AM
Thanks eveyone, figured it was something simple ...

Ian.