如何使用选项调用select标签上的函数 [英] How to call on function on select tag using option

查看:84
本文介绍了如何使用选项调用select标签上的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果从所选标签选项中选择了某些内容,我怎样才能在选择标签上调用选项?



How could i call on selected on an select tag den call on an function when something is selected from selected tag option

(function() {

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


    }
);





我试过这样但我不工作?





= ===================

UPDATE



I have tried like this but i dont work?


====================
UPDATE

$(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");

        };

}

);





更新HTML

================



UPDATE HTML
================

<select id="CalenderListDrop">
       </select>







<select id="LedigTiderDrop">
        </select>

推荐答案

#CalenderListDrop选项:选中)。text(displayfreeTimeonLoad());


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





我试过这样但是我不这样做工作?





====================

UPDATE



I have tried like this but i dont work?


====================
UPDATE


(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 数组(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);

};

}

);
(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"); }; } );





更新HTML

================



UPDATE HTML
================

<select id="CalenderListDrop">
       </select>







<select id="LedigTiderDrop">
        </select>



这篇关于如何使用选项调用select标签上的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆