|
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 |
ermorela Smarty n00b
Joined: 04 Nov 2015 Posts: 4
|
Posted: Wed Nov 04, 2015 3:12 pm Post subject: How to get <li> value |
|
|
Hi all
I'm new to Smarty, trying to develop my fist app.
Need some help in retrieving selected value inside an <ul> .
I'm passing some values from my DB in order to create a Tag Cloud of words, I'd like to retrieve eventually selected value by a user
Code: |
<div id="tags">
<ul>
{foreach from=$words item=row}
{assign var='random' value=1|rand:5}
<li class="tag{$random}"><a href="#">{$row.title}</a></li>
{/foreach}
</ul>
</div>
|
Everything works fine, Tag Cluoud appears.
How could I retrieve selections and pass them to my PHP page?
Thanks in advance for help |
|
Back to top |
|
ermorela Smarty n00b
Joined: 04 Nov 2015 Posts: 4
|
Posted: Thu Nov 05, 2015 11:32 am Post subject: |
|
|
OK found the solution, using JavaScript
in tpl file insert:
Code: |
<head>
<script language="JavaScript" type="text/JavaScript">
{literal}
function lang1($event) {
var target = event.target || event.srcElement;
alert(event.target.innerHTML);
}
{/literal}
</script>
</head>
<body>
<div id="tags">
<ul>
{foreach from=$words item=row}
{assign var='random' value=1|rand:5}
<li id="language" onclick="lang1(event);" class="tag{$random}"><a href="#">{$row.title}</a></li>
{/foreach}
</ul>
</div>
</body>
|
|
|
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
|