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 get <li> value

 
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
ermorela
Smarty n00b


Joined: 04 Nov 2015
Posts: 4

PostPosted: Wed Nov 04, 2015 3:12 pm    Post subject: How to get <li> value Reply with quote

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
View user's profile Send private message
ermorela
Smarty n00b


Joined: 04 Nov 2015
Posts: 4

PostPosted: Thu Nov 05, 2015 11:32 am    Post subject: Reply with quote

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
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