|
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 |
Dwza Smarty Rookie
Joined: 09 Jan 2015 Posts: 7
|
Posted: Fri Jan 09, 2015 12:28 pm Post subject: SmartyFunktion mit JS oder Checkboxevent ausführen... |
|
|
Hi
Sagen wir ich habe in meinem kompilierten Template (demo.tpl)
Lets say i have this in my compiled template (demo.tpl)
Code: | {$foo = '{"aaa":"111","bbb":"222"}'} |
Wenn ich das ausgebe {$foo} bekomme ich wie erwartet
If I output this {$foo} i get following as expacted
Code: | {"aaa":"111","bbb":"222"} |
nun würde ich gerne durch einen click auf einen Button oder einer Checkbox den Wert von bbb ändern. So das ich dann das hier habe:
Now I would like to click a button or a checkbox and change the value of bbb. So I get something like this:
Code: | {"aaa":"111","bbb":"555"} |
In meinem Fall ist es checkbox sein weil etwas an- bzw. ausgeschaltet werden soll.
Und es muss auf dem Template passieren weil ich da auch eine funktion (JS) aufrufe der ich dieses JSON-Array übergeben will.
In my care I want to use checkbox to switch some on and off. And it must
be on the template because im colling a js function there which I want to pass this JSON.
Gibt es da eine möglichkeit?
Is there a possibility?
Dachte da vllt an eine Smartyfunktion die ich aufrufen kann....
Es muss ja was geben weil ich habe auch sowas hier gefunden:
I thought on a smarty-function or some...
There must be some becaue I also fount this:
Code: | <style>
{literal}
td.yellow {
FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Arial,Helvetica;
BACKGROUND-COLOR: yellow;
}
td.red {
FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Arial,Helvetica;
BACKGROUND-COLOR: red;
}
</style>
{/literal}
<table>
<tr>
<tdclass="red" onclick="this.className='yellow'">GELB</td>
</tr>
</table> |
Was auf der TPL die Farbe des elements ändert. Letztendlich will ich ja was ähnliches machen.
What actually changes the color of an element on the template. In the end I want to do some similar. |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Jan 12, 2015 7:16 am Post subject: |
|
|
Verstehe ich das richtig? Du willst eine PHP Variable, die vom "Server" kommt mittels JavaScript (Clientseitig) und im Nachhinein ändern!? Das geht nicht bzw. je nach eigentlichem Ziel...
Und dein Code:
Code: | <td class="red" onclick="this.className='yellow'">GELB</td> |
ändert beim klick nicht eine Variable sondern setzt auf dem geklickten td das attribut "class" von "red" auf "yellow". Das ist jedoch alles HTML/JS. Also sprich nach dem klick würde dein HTMl so ausschauen:
Code: | <td class="yellow" onclick="this.className='yellow'">GELB</td> |
|
|
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
|