2017-06-13 68 views
0

就像我擁有這兩個輸入框一樣。同時通過Web應用程序將數據保存到Firebase中的數據庫時發生

<input type="button" id="valone"> 
    <input type="button" id="valuetwo"> 
    <button type="submit" onClick="submitB();" id="sbmtbtn"> 
    <script> 
    const firstval = findViewById="valueone"; 
    const secondval = findViewById="valuetwo"; 
    const submit = findViewById="sbmtbtn"; 

    const first = firstval.value; 
    const second = secondval.value; 

    function submitB() { 

    const firebaseRef = firebase.database().ref().push(); 

    firebaseRef.child("Value").child("Value One").set(first.value); 
    firebaseRef.child("Value").child("Value Two").set(second.value); 

       } 

但它確實這個形象像.......

image of database please see

它顯示空白沒有輸入框的值

請幫我所有的依賴性都設置正確加載,一切都很好。

+0

'findViewById'應該是一個函數嗎? –

回答

0

您正試圖查找HTML元素,但正在使用不存在的函數。您正在尋找getElementById(),像這樣:

<input type="button" id="valone"> 
<input type="button" id="valuetwo"> 
<button type="submit" onClick="submitB();" id="sbmtbtn"> 
<script> 
const firstElm = findElementById("valueone"); 
const secondElm = findElementById("valuetwo"); 
const submitBtn = findElementById("sbmtbtn"); 

const first = firstElm.value; 
const second = secondElm.value; 

function submitB() { 
    const firebaseRef = firebase.database().ref().push(); 

    firebaseRef.child("Value").child("Value One").set(first); 
    firebaseRef.child("Value").child("Value Two").set(second); 
} 
+0

對不起,我在這裏輸入錯誤,但它也不起作用 –

相關問題