Possible Duplicate:
Pass a PHP string to a Javascript variable (and escape newlines)
I am using javascript to do some form validation on a php page. There are several parts to it, but a typical one looks like this:
var brek=document.forms["seasonprice"]["price_brek"].value
if (brek==0)
{
alert("<?php echo $lang["brekzero"] ?>");
return true;
}
$lang['brekzero'] is defined in an included language file. As the text is fairly long I want to break it up onto several lines for better readability. I expected to be able to do that by inserting \n in the appropriate places. Instead it stops the alert working altogether, and it took me a long time to identify that as the cause.
What should I be doing instead?
The same script has also been giving me problems with accented letters. Writing á in the lang file results in á appearing in the alert instead of á. Writing á in the lang file causes strange symbol to appear in the alert. For the moment I've taken the very English way out, and left out the accents!