Click to See Complete Forum and Search --> : Insert a speechmarks into a string or page


GlennCarter
11-27-2003, 05:50 AM
Hi,

This is going to seem a really stupid question but I'm a newb to Javascript so please bear with me.

I'm looking for a function that puts in a character from the ascii value - something like: Chr(No) in VBScript. The specific charactor I wish to insert is speechmarks " . To this end I wrote a little function that I thought would do it however it keeps returning the error: Object doesn't support this property or method.

The code is thus:

function insSpeechMarks() {
var SpStr = String.fromcharcode(34) ;
return SpStr;
}

I appreciate there's probably a much simpler way of doing this so if anyone could tell me that then that would be a great help as an alternative to telling me why my code is wrong.

Khalid Ali
11-27-2003, 06:19 AM
can you re-phrase your question please..;)

GlennCarter
11-27-2003, 06:24 AM
Yes.

How do I concatenate a string with speechmarks?

I have a string, for example: TEST STRING
I want to make it: "TEST STRING"

Thanks

ccoder
11-27-2003, 07:24 AM
Here are several ways to do it.

document.write("\"" + "TEST STRING" + "\"");
document.write('"' + 'TEST STRING' + '"');

GlennCarter
11-27-2003, 07:36 AM
Works a treat. Thank you.