Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  176] [ 7]  / answers: 1 / hits: 17565  / 15 Years ago, thu, august 13, 2009, 12:00:00

I got a problem regarding how to assign a java script variable to a smarty variable. Here is the code snippet.



function getDateInfo(date, wantsClassName)
{
var as_number = Calendar.dateToInt(date); //This as_number is the variable which should be assigned to smarty variable
}


How can i accomplish this.



any help will be appreciated..



Thanks n advance -- Fero


More From » smarty

 Answers
2

You can't assign a client-side value to a smarty variable, as smarty is a templating language that runs on the server. Smarty assignments can only be done on the server-side, that is to say, from PHP. E.g.:



$smarty->assign('timestamp',time());


So what you can do is something like:



    $smarty->assign('timestamp',time()); //in your PHP script

//in your JS
var currentTS = {$timestamp};


See http://www.smarty.net/manual/en/api.assign.php


[#98925] Saturday, August 8, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zaynerogerb

Total Points: 454
Total Questions: 109
Total Answers: 97

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
zaynerogerb questions
;