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

how to use get_template_vars

 
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
Cindy Lu
Smarty n00b


Joined: 08 Jan 2004
Posts: 3

PostPosted: Fri Jan 09, 2004 3:29 am    Post subject: how to use get_template_vars Reply with quote

Can I get the value using get_template_vars in php before the form got submit :

template.tpl
<select name ="box">
<option>option1</option>
<option>option2</option>
</select>
{include_php file="my.php"}
<input type=text name=myoutput value="{$result}">

my.php
<?php
$myinput = $this->get_template_vars("box");
//do mysql here to get data from database.
//and get the sql result - $sqlresult
$smarty->assign('result',$sqlresult);
?>

I tried that, but I can not the the value of box using get_template_vars before the forms got submit. Anyone can tell me whether I am right or wrong? How can I do that?

Can I do that in javascript after I got the selection value for 'box'? But how can I talked to the database in javascript?

Thanks!

Cindy
_________________
Cindy Lu
Back to top
View user's profile Send private message
Gerald
Smarty Regular


Joined: 26 Nov 2003
Posts: 53
Location: Lyon [France]

PostPosted: Fri Jan 09, 2004 7:47 am    Post subject: Reply with quote

Her, not sure what you're trying to do here..... but

You can't "talk to" the database in javascript. Javascript is a client side language. It is launched inside the browser.

PHP is a server language, therefore, you can only deal with what the user sends you (url, form data, ...). That mean that you can't know a form value before the user sends his form.

PHP and Javascript can't talk to each other (except if by "talk together" you consider javascript generation in PHP, or javascript url generation to "call" a PHP page)

Hope this helps...
Back to top
View user's profile Send private message Visit poster's website
Cindy Lu
Smarty n00b


Joined: 08 Jan 2004
Posts: 3

PostPosted: Fri Jan 09, 2004 1:32 pm    Post subject: RE: How to use get_template_vars Reply with quote

Thanks a lot! It cleared up my mind.

Cindy
_________________
Cindy Lu
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