3

The following code displays {$products[i]} tag inside the select menu.I tried {literal} but not succeeded.Please tell me how to make this function?.Where I should put {literal} or {rdelim} tags?.

My javascript codes are in an external file and I call this function to add new table data.

item_td.innerHTML="<select>{section name=i loop=$products} <option value='{$products[i]}' >&nbsp;{$products[i]}&nbsp;</option> {/section} </select>";

Regards.

2
  • 6
    If you're expecting Smarty to parse your external JS files which you add to your page via <script src="... it isn't gonna happen without some sort of PHP system to read the JS and pass it to Smarty... Commented Jun 17, 2011 at 16:53
  • 1
    To add to one of Noxt's comments, you can create a global variable in your smarty template which can be used by your external file. See this question on some techniques how: stackoverflow.com/questions/6340470/… Commented Jun 17, 2011 at 18:12

1 Answer 1

-1

try this code

item_td.innerHTML="<select>{/literal}{foreach from=$products item=product} <option value='{$product}'>&nbsp;{$product}&nbsp;</option>{/foreach}{literal} </select>";

you may need to add / delete {literal}

Sign up to request clarification or add additional context in comments.

6 Comments

@Noxt Thanx for the nice try , I tried that but not worked.I do almost everything with {literal} tags.Nothing worked for me.
if you put {literal} at the beginning of JS code, and in the end it does not work?
@Noxt, as far as I can understand, his code is in an external JS file. No amount of smarty tags will make this work without an infrastructure change.
@JAAulde, you're right, I did not notice that JS is in an external file.
@Noxt, and just so you know, it was not me who gave your answer a -1
|

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.