3

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>
2
  • 1
    what have you try so far Commented Jan 19, 2016 at 2:05
  • my php value is stored in $biz_product->related_products. I tried if ($biz_product->related_products == {{filename}}) Commented Jan 19, 2016 at 2:11

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.