[Javascript] String on multiple lines

Peter Lauri lists at dwsasia.com
Mon Jun 19 11:50:23 CDT 2006


Best group member,

 

I have a "silly problem" and the here it is:

 

I have a variable in PHP that is like $variable. The content of this is
separated with \n to linebreaks. I want to use this and pass it to the
Javascript that I have so I do something like this:

 

..javascript stuff.

 

function JavaScriptFkn() {

            var variable = "<?php echo $variable; ?>";

}

 

.. Javascript stuff..

 

That ends up to be like this:

 

function JavaScriptFkn() {

            var variable = "The first row.

<p>The second row.</p>

<h1>The third row</h1>";

}

 

As you see, the row is split up, and the javascript will not see the rows.
Is there any way of getting around this? I know I can probably solve this in
PHP by taking away the \n that is destroying my day. Anyone with a simple
and workable solution? 

 

Best regards,

Peter Lauri

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060619/f07f0210/attachment.htm>


More information about the Javascript mailing list