У меня есть этот код, ссылки на базу данных помечают меня правильно и добавляются в выбор, но я не могу сохранить их правильно в Firebase при их выборе.
Есть ли другой способ сделать это? Какие у меня ошибки? и я надеюсь объяснить себя хорошо.
Ошибка, которая отмечает меня, заключается в следующем:
Uncaught ReferenceError: keyBase не определено при сохранении (index.html: 152) в HTMLButtonElement.onclick
let inst = {};
const instRef = firebase.database().ref('ies');
instRef.on('value', snap => {
inst = null;
inst = snap.val();
let aux = 1;
const selector = document.getElementById('select');
$.each(inst, (indice, valor) => {
selector.options[aux] = new Option(valor.nombre, valor.nombre);
aux++;
});
});
let per = {};
const perRef = firebase.database().ref('periodos');
perRef.on('value', snap => {
per = null;
per = snap.val();
let aux = 1;
const selector = document.getElementById('optiones');
$.each(per,(indice, valor) => {
selector.options[aux] = new Option(valor.nombre, valor.nombre);
aux++;
});
});
guardar = () =>{
const d = document.getElementById('select');
const displayText = d.options[d.selectedIndex].text;
const a = document.getElementById('optiones');
const display = a.options[a.selectedIndex].text;
firebase.database().ref(keyBase).set({
folio:$('#folio').val(),
nombre: $('#name').val(),
apellidos: $('#apellido').val(),
municipio: $('#mun').val(),
numcel: $('#cel').val(),
ies: displayText,
periodos: display
});