|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Smitty28 Smarty n00b
Joined: 12 May 2005 Posts: 2
|
Posted: Thu May 12, 2005 12:53 pm Post subject: how to use javascript variables in smarty tags ? |
|
|
Hello for all.
I'm just new in this forum and already have a question:
how can I use javascript variables within a smarty tag ?
e.g.:
in a javascript-function i get the parameter "displine".
the function shall take a value from the smarty-array an display it to the browser.
-----
{literal}
<script type="text/javascript">
function DisplayTheLine (displine)
{
{/literal}
document.write('The value of the line is: '+{$linearray[displine].LINE_VALUE});
document.write('<BR>');
{literal}
}
</script>
{/literal}
-----
But smarty does not know displine within the smarty-tag {$linearray...}
How can I solve that problem ?
Thanks a lot for your help !
Smitty28 |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu May 12, 2005 1:37 pm Post subject: |
|
|
I know this doesn't solve the problem, but at the time the template is parsed, javascript variables have no values. Smarty sees javascript as text, just like any other HTML. Only after the templates rendered, the browser picks up the resulting text and executes the javascript.
Also, this:
{$linearray[displine].LINE_VALUE}
Will certainly not work, as [displine] would be a section name in Smarty, not a variable index. |
|
Back to top |
|
Smitty28 Smarty n00b
Joined: 12 May 2005 Posts: 2
|
Posted: Fri May 13, 2005 8:20 am Post subject: |
|
|
Hmmm...
sounds logical.
So I'l try to do a workaround.
Thanks a lot for the info, it was nevertheless helpful.
Much Greetings
Smitty |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|