Quote:
Originally Posted by kh99
Try this:
PHP Code:
$jsstring = addcslashes(nl2br(htmlspecialchars($option)), "'\\");
Where $option is the string from the database, and $string is what you'll use in your template for the js variable, in single quotes, like:
Code:
var jsvar = '$jsstring';
This assumes that what's being entered and saved in the db is not html. If it is, you don't want the htmlspecialchars() in there (and then they really should be entering the <br> tags themselves, but that's OK).
Edit: Another thought - you could allow bbcode markup, and then when you pass it through the bbcode compiler it will change \n to <br>.
The templates are html, so you'd have to explicitly use <br> where you wanted them in the output.
|
So close, but yet it doesn't work. :/
Basically, if I've still been unclear, I'm calling the variable (which I declare in a template):
Code:
<script type="text/javascript">
<!--
var RULES = "$vboptions[ishout_rules]";
// -->
</script>
Into my .js file:
Code:
InfernoShoutbox.userframe.innerHTML = RULES;
So, my problem is basically how do I manipulate the input in the ACP in JavaScript and
not in PHP?