Click here to Skip to main content
15,917,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How could i call on selected on an select tag den call on an function when something is selected from selected tag option

JavaScript
(function() {

        $("#CalenderListDrop option:selected").text(displayfreeTimeonLoad());


    }
);


I have tried like this but i dont work?


====================
UPDATE
C#
$(document).ready(function () {

    var getListCalender = document.getElementById('CalenderListDrop');
    spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    context = new SP.ClientContext.get_current();
    parentContext = new SP.AppContextSite(context, spHostUrl);
    web = parentContext.get_web();
    var allLists = web.get_lists();
    context.load(allLists);
    context.executeQueryAsync(
            function () {

                var listEnumerator = allLists.getEnumerator();
                while (listEnumerator.moveNext()) {
                    var listName = listEnumerator.get_current();
                    var listTypeId = listName.get_baseTemplate();

                    if (listTypeId == SP.ListTemplateType.events) {

                        var array = new Array(listName.get_title());

                        for (var i = 0; i < array.length; i++) {

                            var opt = document.createElement("option");
                            getListCalender.options.add(opt);
                            opt.text = array[i];
                            opt.value = array[i];

                        }

                    }
                    break;
                }

            }

            ),
        function () {
            alert("Eror");

        };

}

);


UPDATE HTML
================
XML
<select id="CalenderListDrop">
       </select>


JavaScript
<select id="LedigTiderDrop">
        </select>
Posted
Updated 8-Dec-14 23:19pm
v3
Comments
DamithSL 9-Dec-14 4:56am    
please update with your html code
Kurac1 9-Dec-14 5:19am    
I have updated.

1 solution

JavaScript
$(document).ready(function()
{
   $('#CalenderListDrop').on('change', function() {
     //do something...
     $("#CalenderListDrop option:selected").text(displayfreeTimeonLoad());
   });
});
 
Share this answer
 
v3
Comments
Kurac1 9-Dec-14 4:54am    
I doesnt work, nothing happens the function dont trigger,
i will update what i have in my select tag option code.
DamithSL 9-Dec-14 11:24am    
check my updated answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900