How to pass a value from php to javascript? I'm working with smarty and i tried this but js seems to take it as a a string. The value is set to 20.
$smarty->assign('settings', $settings); //$settings is an array
$settings is coming from an file, basically it are some settings. i want to select an option in an html doc with that value but it is not working.
<select id="entrys">
<option>5</option>
<option>10</option>
<option>20</option>
</select>
and in the js file then:
$(document).ready(function()
{
$('#entrys').val("{$settings['frontendEntrys']}");
});
But no option is selected then not even the first or default value and if i try to print {$settings['frontendEntrys']} it's also not working. It just seems to be taken as a string.
BTW: Is it a good way to pass some settings with smarty or generally? How can i pass the values if i don't use smarty? Would this be correct? Is this a good way, if it's done in an html file?
<script>
var data = <?php echo $settings['entrys']; ?>
</script>