2016-05-15 47 views
0

工作,我有一個表:的document.getElementById不在JS

<tr> 

    <td><input type="text" name="remaining_quantity" id="remaining_quantity" value="<?php if(isset($quantity)) echo $quantity; ?>"/></td> 

    <td><input type="text" name="remaining_price" id="remaining_price" value="<?php if(isset($price)) echo $price; ?>" /></td> 

    <input type="button" class="check fr ml" value="Check" id="check_equation" onclick="get_full_status()" /> 

</tr> 

我想找到的值輸入字段,因此,

function get_full_status(){ 
    var remaining_quantity = document.getElementById('remaining_quantity').value; 
    var remaining_price = document.getElementById('remaining_price').value; 
    alert(remaining_quantity);alert(remaining_price); 
} 

我沒有得到實際值。如果你不明白問題,請問我。

+2

在控制檯中是否有任何錯誤?警報返回值是什麼? – Pierfrancesco

+0

控制檯中沒有錯誤。它警報空白。 – yank

+0

您是否檢查過'value'屬性? *它有任何價值嗎? – haim770

回答

-1

我檢查了jsfiddle上的同樣的東西,它工作正常。 https://jsfiddle.net/b13gtff0/

function get_full_status(){ 
      var remaining_quantity = document.getElementById('remaining_quantity').value; 
      var remaining_price = document.getElementById('remaining_price').value; 
      alert(remaining_quantity);alert(remaining_price); 
} 

我覺得這裏的問題可能是服務器沒有返回任何值。 或者可能是一些PHP語法問題。 我的建議是可以請你檢查從服務器返回的響應。

當你點擊控制檯上的按鈕時,你也會看到任何異常。

+0

這裏是沒有錯誤的jsfiddle,但我得到了問題在我的代碼 – yank

+0

任何異常? – Bkjain655

+0

誰投了票?如果你敢回答這個問題..我們所有人都給予回答很容易downvote – yank

相關問題