Javascript document.getElementById在js中不起作用
我有一张桌子:Javascript document.getElementById在js中不起作用,javascript,Javascript,我有一张桌子: <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="rema
<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>
我没有得到实际价值。如果你不明白这个问题,问我 我在jsfiddle上检查了相同的东西,它工作正常。 我觉得这里的问题可能是服务器没有返回任何值。 或者可能是一些php语法问题。 我的建议是,请您检查服务器返回的响应
当您单击控制台中的按钮时,您是否看到任何异常。您是否在控制台中看到任何错误?警报返回值是多少?控制台中没有错误。它为空。您是否检查了
值
属性?它有任何值吗?没有错误意味着getElementById()
工作正常。$quantity
和$price
的值是多少?呈现模板时,value=”“
属性是否为空?是的,值为整数值JSFIDLE中没有错误,但我的代码中有问题谁投了反对票?如果你敢回答这个问题。。我们都知道给出的答案很容易被否决,那么你就否决了错误的答案。你应该对这个问题投反对票,而不是对答案投反对票。当你的答案出现在屏幕上时,我可能点击了问题的向下投票按钮。这可能是一个堆栈溢出错误。如果你修改你的答案,我的反对票将被取消。
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);
}
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);
}