Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to put a value within some javascript code like so:

<?
$page = "test";

echo ('<script id="template-download" type="text/x-jquery-tmpl">
<tr class="template-download{{if error}} ui-state-error{{/if}}">
    {{if error}}
        <td class="name" style="display: none;">${name}</td>
        <td class="size" style="display: none;">${sizef}</td>
.....etc...
            {{if thumbnail_url}}
                <img src="Img/');
                $page;
                echo('.jpg">
            {{/if}}
.....etc....
</script>');
?>

And the end value looks like this:

            {{if thumbnail_url}}
                <img src="Img/.jpg">
            {{/if}}

and it doesn't put the value? What am i missing???

David

share|improve this question
    
What does the output look like? –  NullUserException Sep 9 '11 at 4:24

2 Answers 2

up vote 6 down vote accepted

You're not echoing page.

echo $page;
share|improve this answer
    
Ah yes, of course. Ha. Thanks :o) –  StealthRT Sep 9 '11 at 4:30
    
It's always the silly ones that are the hardest to spot, cos your brain just assumes they're correct :) –  Joe Sep 9 '11 at 4:31

thats because you're using single quotes so echo doesnt evaluates $vars and like Joe said, particulary $page is not being echoed

share|improve this answer
    
Same as the winning one so thanks as well :o) –  StealthRT Sep 9 '11 at 4:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.