I cannot for the life of me realise what is wrong with this code.
<? if (empty($nick)): ?>
$('#nickTextbox').val(chatmoreDefaults.nick);
<? else: ?>
$('#nickTextbox').val(null);
<? endif; ?>
<? if (empty($realname)): ?>
And the first line gives me the error Uncaught SyntaxError: Unexpected token <
Any ideas of how I can remove that error?
2 Answers 2
You need to use <?php or <?= if short tags are enabled.
Comments
The logic is useless... there's no difference between setting a textbox to an empty string or null. It will be an empty string.
Mixing content like this is a bad idea. I would suggest passing any server values that the JS needs, and setting them as a JSON/JObject variable for javascript. Then doing your checks in JS.
There's not enough context as to how you are sending any of this information or where it fits.
As another answer mentions...
<?php
<?php ... ?>tags.