Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

calling function of smarty variable in onclick of button

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
pascalVG
Smarty n00b


Joined: 03 Mar 2013
Posts: 2

PostPosted: Sat Jan 25, 2014 8:37 am    Post subject: calling function of smarty variable in onclick of button Reply with quote

Hi there,

I have a smarty variable $customer assigned in a controller file.

What I try is to call a function of this variable:
$customer->myFunction(language_id, password);

And want to do this from within or through the onclick of a button in my tpl file.

something like:
<input type="text" name=password" id="password" title="password" size="10" maxlength="10" />

<input type="button" name="my_button" id="my_button" value="Go" onclick="{$customer->myFunction($language_id, $('password').val())};" />


The page renders, but no button...

Any idea how to make this work???

thanks
Back to top
View user's profile Send private message
gyopee
Smarty Rookie


Joined: 27 Jan 2014
Posts: 14

PostPosted: Mon Jan 27, 2014 11:21 am    Post subject: Reply with quote

Smarty template codes are executed before the client sees anything from your template.
So that, you cannot set a Smarty function to listen to a user action (the Smarty function is already evaluated when the user performs his/her action).

You must use JavaScript to achieve your goal.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP