MyBB Community Forums

Full Version: how can i use condition in themplate by javascript ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
why this code is not correct?

<script type="text/javascript">
 document.write({$multipage});
 </script>

output is :
);

what is the correct format ?
<script type="text/javascript">
document.write('{$multipage}');
</script>

Does that work?
no it doesnt work.

(2013-09-09, 04:52 PM)gnostic Wrote: [ -> ]why blow code is not correct?

<script type="text/javascript">
 document.write({$multipage});
 </script>

output is :
);

what is the correct format ?

how can i write {$mybb_element} in javascript.
Can you post an extract of the HTML output?
the output is :

[Image: 41298226262666887842.png]

this error get because i use {$welcomeblock}\, i dont khow how can show {$welcomeblock} in javascript.
i use php echo command too, but i get above error.
You're not escaping the string. You need to put a backslash before each single quote.
in header template :
[Image: p91_Untitled44.png]

i want, when my condition is true,{$welcomeblock} apear and else no apear.
but blow code is not correct :

<script type="text/javascript">
if (my condition is true)
 {
{$welcomeblock}
 }
 else
 {
 }
</script>

and output of above code is :

[Image: w8495_Untitled11.png]

this error get because i use {$welcomeblock}, i dont khow how can show {$welcomeblock} in javascript.
i use php echo command too, but i get above error.
developers plz help me...
I'm not sure you can actually do what you are trying to do there because you are using a variable in PHP within a section of javascript. PHP is parsed server side while Javascript is client side.