Am getting the error of firebase.database is not a function when tryna use update syntax using javascript. here are my 2 files
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- database
Direzione di ricerca
Inizia leggendo lo script di modulo inline nell’HTML fornito e js2.js, quindi riproduci l’errore firebase.database con il flusso di aggiornamento mostrato. Confronta gli import di Firebase e l’inizializzazione con il punto di ingresso dell’aggiornamento; il lavoro è completato quando il record UsersList viene aggiornato senza il TypeError segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
<style>
.labs{
display: inline-block;
width: 100px;
}
</style>
</head>
NFC MTC GRAB CUSTOMERS
<div class="container mt-3">
<div class="input-group mb-3">
<input id="SearchBar" type="text" class="form-control" placeholder="Search using the" aria-label="Recipient's username" aria-describedby="button-addon2">
<div class="input-group-append">
<select class="custom-select" id="CategorySelected">
<option selected value="1">name</option>
<option value="2">username</option>
<option value="3"> email</option>
<option value="4"> password</option>
</select>
<button id="SearchBtn" class="ml-1 btn btn-outline-info" type="button" id="button-addon2">SEARCH</button>
</div>
</div>
Back
Add User
Add driver
Driver's list
</thead>
<tbody id="tbody1">
</div>
Control Pannel
× Full name:Username:
Email:
Password:
<div class="modal-footer">
<button id="AddModBtn" type="button" class="btn btn-info" onclick="Addstd()">Add</button>
<button id="UpdModBtn" type="button" class="btn btn-success" onclick="Updstd()">Update</button>
<button id="DelModBtn" type="button" class="btn btn-danger" onclick="Delstd()">Delete</button>
</div>
</div>
</div>
| Sno | Full Name | Username | password | Control Center |
|---|
<script type="module">
function AddItemToTable(fullname,username,email,password) {
var tbody = document.getElementById("tbody1");
let tr = document.createElement("tr");
let td0 = document.createElement("td");
let td1 = document.createElement("td");
let td2 = document.createElement("td");
let td3 = document.createElement("td");
let td4 = document.createElement("td");
stdList.push([fullname,username,email,password]);
td0.innerHTML = ++stdNo;
td1.innerHTML = fullname;
td2.innerHTML = username;
td3.innerHTML = email;
td4.innerHTML = password;
td1 .classList +="nameField";
td2.classList +="dateField";
td3.classList +="timeField";
td4.classList +="phoneField";
tr.appendChild(td0);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
var ControlDiv = document.createElement("div");
ControlDiv.innerHTML = '<button type="button" class="btn btn-info" my-2 ml-2" data-toggle="modal" data-target="#exampleModalCenter" onclick = "FillTboxes('+stdNo+')"> Edit </button>';
ControlDiv.innerHTML += '<button type="button" class="btn btn-info" my-2 ml-2" data-toggle="modal" data-target="#exampleModalCenter" onclick = "FillTboxes(null)"> Add </button>';
tr.appendChild(ControlDiv);
tbody.appendChild(tr);
}
function AddAllItemsToTable(TheStudent) {
stdNo = 0;
tbody.innerHTML = "";
TheStudent.forEach(element => {
AddItemToTable(element.fullname, element.username, element.email,element.password );
});
}
//............................................gettign data........................//
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.8.3/firebase-analytics.js";
const firebaseConfig = {
apiKey: #######
authDomain: #############
databaseURL: ############
projectId: #########
storageBucket: ###########
messagingSenderId: #########
appId: ########
measurementId: #########
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
var stdNo;
import {getDatabase, ref , child, onValue, get}
from "https://www.gstatic.com/firebasejs/9.8.3/firebase-database.js";
const db = getDatabase();
function GetAllDataOnce(){
document.getElementById("tbody1").innerHTML="";
stdNo = 0;
const dbref = ref(db);
get(child(dbref, "UsersList"))
.then((snapshot)=>{
var students =[];
snapshot.forEach(childSnapshot =>{
students.push(childSnapshot.val());
});
AddAllItemsToTable(students);
});
}
window.onload = GetAllDataOnce;
var searchBar = document.getElementById("SearchBar");
var searchBtn = document.getElementById("SearchBtn");
var category = document.getElementById("CategorySelected");
var tbody = document.getElementById("tbody1");
function SearchTable(Category){
var filter = searchBar.value.toUpperCase();
var tr = tbody.getElementsByTagName("tr");
var found;
for (let i = 0; i < tr.length; i++) {
var td = tr[i].getElementsByClassName(Category);
for ( let j = 0; j < td.length; j++) {
if(td[j].innerHTML.toUpperCase().indexOf(filter) > -1){
found=true;
}
}
if(found){
tr[i].style.display="";
found=false;
}
else{
tr[i].style.display="none";
}
}
}
searchBtn.onclick = function(){
if(searchBar.value==""){
SearchTable("nameField");
}
else if(category.value==1)
SearchTable("nameField");
else if(category.value==2)
SearchTable("dateField");
else if(category.value==3)
SearchTable("timeField");
else if(category.value==4)
SearchTable("phoneField");
};
</script>
<script src="js2.js"></script>
var firebase= {
apiKey: ########
authDomain: ###########
databaseURL: #############
projectId: ########
storageBucket: ##########
messagingSenderId:#########
appId: ############
measurementId: ###########
};
var stdNo = 0;
var stdList =[];
var ModName = document.getElementById('NameMod');
var ModRoll = document.getElementById('RollMod');
var ModSec = document.getElementById('SecMod');
var ModPass = document.getElementById('PassMod');
var BTNmodAdd = document.getElementById('AddModBtn');
var BTNmodUpd = document.getElementById('UpdModBtn');
var BTNmodDel = document.getElementById('DelModBtn');
function FillTboxes (index){
if(index==null){
ModName.value = "";
ModRoll.value = "";
ModSec.value = "";
ModPass.value = "";
BTNmodAdd.style.display='inline-block';
BTNmodUpd.style.display='none';
BTNmodDel.style.display='none';
}else{
--index;
ModName.value = stdList[index][0];
ModRoll.value = stdList[index][1];
ModSec.value = stdList[index][2];
ModPass.value = stdList[index][3];
ModPass.disabled = true;
BTNmodAdd.style.display='none';
BTNmodUpd.style.display='inline-block';
BTNmodDel.style.display='inline-block';
}
}
function Updstd(){
firebase.database().ref('UsersList/'+ModRoll.value).update(
{
fullname: ModName.value,
username: ModRoll.value,
email : ModSec.value,
password : ModPass.value
},
(error) =>{
if(error){
alert("failed to update the records");
}else{
alert("success updated");
GetAllDataOnce();
$("exampleModalCenter").modal('hide');
}
}
)
}
function Delstd(){
firebase.database().ref('UsersList/'+ModRoll.value).remove()
alert("deleted successfully");
GetAllDataOnce();
$("exampleModalCenter").modal('hide');
};
- Lingua principale
- JavaScript
- Stelle
- 1.9k
- Fork
- 1.8k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firebase/codelab-friendlychat-web
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
RunApertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
firebase/codelab-friendlychat-web#877 · 2 commenti ·
-
Go to '...'Apertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
-
CameraAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Sifsin projectApertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
firebase/codelab-friendlychat-web#837 · 1 reazione ·
Tutte le issue di firebase/codelab-friendlychat-web
Issue simili
-
bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
jellyfin/jellyfin-web#8865 ·
I maintainer di solito rispondono entro 1 giorno
-
renderer.44: a zoom out cannot keep the center and stay inside data.range at an end of the dataApertaarea:contract P3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
grafana/viz-contract#100 ·
I maintainer di solito rispondono entro 1 giorno
-
SUB-1: [CI] Update deprecated CodeQL Action v2 to v4Forse già presa @AnkitSatpute l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 93/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100