如何使用Javascript在Firebase数据库中使用特定键名获取值

时间:2019-01-16 08:01:59

标签: javascript firebase firebase-realtime-database

我被困在一个非常糟糕的时刻。我正在使用firebase(用于数据库)和Javascript开发Web应用程序。

这是我的Firebase数据库的结构。

enter image description here

我想在下拉输入栏中显示这些类别,但要使每个子类别都以此方式显示在其父类别输入栏中

这就是我想要的 enter image description here

这是我的代码

var newTask = firebase.database().ref("childCategory");
    newTask.on('value', function(snapshot){
        snapshot.forEach(function(childSnapshot) {
            var taskValue = childSnapshot.val();
            document.getElementById("selectCatigory").innerHTML +=
            <optgroup label="${taskValue.parentCategory}">
             snapshot.forEach(function(childSnapshot){
             var tasksValue = childSnapshot.val();
            document.getElementById("selectCatigory").innerHTML +=
            <option label="${tasksValue.childCName}"> </option> </optgroup>
            });
        });
    });

0 个答案:

没有答案