2016-05-15 48 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

相关问题