如何在javascript中进行选择时过滤数据

时间:2017-07-14 09:32:57

标签: javascript php html frameworks

这是我从数据库中提取数据的选择ID

HTML

var jsonData = [{"id":"jmbaaaro@kaps.co.ke","passkey":null},{"id":"willson@gmail.com","passkey":"3694"},{"id":"info@llvswaterboard.go.ke","passkey":null},{"id":"rundda@athiwater.com","passkey":"5576"},{"id":"pk@.k.com","passkey":"1835"},{"id":"pkinnyanjui@kaps.co.ke","passkey":null},{"id":"wilsson@gmail.com","passkey":"3694"}{"id":"wycllif@kaps.co.ke","passkey":"2318"},{"id":"wycllif@gmail.com","passkey":"2318"},{"id":"alexx@gmail.com","passkey":"2710"},{"id":"wilsson@gmail.com","passkey":"3694"},{"id":"barbeggambo@gmail.com","passkey":"8917"},{"id":"bachu@gmail.com","passkey":"5857"}]

JSON

 var jsonData = JSON.parse(data);
    //var jsonData = JSON.parse(s);
    var select = $$('#mySelectID');
    for (var i = 0; i < jsonData.length; i++) {
        var option = $("<option/>").attr("value",jsonData[i].id).text(jsonData[i].id);
       select.append(option);
    }   

    $("select#mySelectID").change(function(){
       var selectedmail = $("#mySelectID").val();
       var s = jsonData.filter(function (e){
       return e.id ==='3694';
    });

JAVASCRIPT

li.col-sm-3:nth-child(5) {
    clear: both;
}

我试图通过密码3694获取值。请协助我是javascript的新手。

0 个答案:

没有答案