This is a migrated thread and some comments may be shown as answers.

how to get the value of anchor tag selected from a Menu item consisting of item template

1 Answer 431 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Vaibhav
Top achievements
Rank 1
Vaibhav asked on 22 Feb 2014, 09:38 AM
Hi ,

I have a menu in which i am creating a mega dropdown by using itemtemplate.
I want to retrieve the value of list inside my anchor tag  <a> tag which is inside a <div> , selected by the user.

And if some one could also help me where i can assign the value to the anchor tag <a>, as it does not support the property of value.
Basically here is  a small snippet -
 <a href="#">
                                                <li>French</li>
                                            </a>

So when a user hit on French from menu , i want to return the "fr" in back-end. and perform the localization .

here is the complete code for my RadMenu-

<telerik:RadMenu ID="sMenuLanguage" runat="server" Width="7%" Font-Size="14px" EnableEmbeddedSkins="False">
        <Items>
            <telerik:RadMenuItem Text="English">
                <Items>
                    <telerik:RadMenuItem CssClass="rmSlide1" OuterCssClass="langSlide">
                        <ItemTemplate>
                            <div class="main">
                                <h2 class="main-title">AROUND THE GLOBE - SELECT YOUR LANGUAGE </h2>
                                <div class="map">
                                    <img src="../images/map.png" />
                                </div>

                                <div id="languageSection" class="languageSection">
                                    <div class="col">

                                        <ul>
                                            <a href="#">
                                                <li>Chinese (Simple)</li>
                                            </a>
                                            <a href="#">
                                                <li>Chinese (Traditional)</li>
                                            </a>
                                            <a href="#">
                                                <li>Danish</li>
                                            </a>
                                            <a href="#">
                                                <li>Dutch</li>
                                            </a>
                                            <a href="#">
                                                <li>English</li>
                                            </a>
                                        </ul>
                                    </div>
                                    <div class="col">

                                        <ul>
                                            <a href="#">
                                                <li>Finnish</li>
                                            </a>
                                            <a href="#">
                                                <li>French</li>
                                            </a>
                                            <a href="#">
                                                <li>German</li>
                                            </a>
                                            <a href="#">
                                                <li>Italian</li>
                                            </a>
                                            <a href="#">
                                                <li>Japanese</li>
                                            </a>
                                        </ul>
                                    </div>
                                    <div class="col">
                                        <ul>
                                            <a href="#">
                                                <li>Korean</li>
                                            </a>
                                            <a href="#">
                                                <li>Norwegian</li>
                                            </a>
                                            <a href="#">
                                                <li>Portuguese</li>
                                            </a>
                                            <a href="#">
                                                <li>Spanish</li>
                                            </a>
                                            <a href="#">
                                                <li>Swedish</li>
                                            </a>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </ItemTemplate>
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>


Could any one help me on this , how can we achieve this , with a small piece of sample code

Thanks 







1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Feb 2014, 06:20 AM
Hi Vaibhav,

Please try the following code snippet to access the Value field of anchor tag from client side.

ASPX:
<a href="#" onclick="Demo(this);" value="fr">
    <li>French</li>
</a>

JavaScript:
<script type="text/javascript">
    function Demo(anchor) {
        var value = anchor.getAttribute('value')
        alert(value);
    }
</script>

Thanks,
Shinu.
Tags
Menu
Asked by
Vaibhav
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or