I have a template consisting of a checkbox and a value retrieve from php.
How can I compare the php value with the value of {{filename}}? It the two value matched, then set the checkbox to checked.
<script type="text/template" id="imageTemplate">
<div class="row gc_photo" id="gc_photo_{{id}}" style=" border-bottom:1px solid #ddd; padding-bottom:20px; margin-bottom:20px;">
<div class="checkbox">
<label>
<input onclick="return set_parentimage(this);" type="radio" name="primary_image" id="{{id}}_{{filename}}" value="{{id}}" {{#primary}}checked="checked"{{/primary}}/> <?php echo lang('main_image');?>
</label>
</div>
</div>
</script>
Try using this i came across earlier ...... It was suggested to me. My problem was kind similar to yours. Here i send a value from PHP to javascript. Hope it will help you.
<?php
//somewhere set a value
$var = "a value";
?>
<script>
// then echo it into the js/html stream
// and assign to a js variable
spge = '<?php echo $var ;?>';
// then
alert(spge);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With