简体   繁体   English

document.getElementById在JS中不起作用

[英]document.getElementById is not working in js

I have a table : 我有一张桌子:

<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>

I want to find the value to input field so, 我想找到要输入的值,所以,

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);
}

I don't get actual value. 我没有得到实际价值。 If u don't understand question ask me. 如果你不明白问题,请问我。

I checked the samething on jsfiddle and it is working fine. 我在jsfiddle上检查了同样的东西,它工作正常。 https://jsfiddle.net/b13gtff0/ 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);
}

I feel like here the issue could be server is not returning any value. 我觉得这里的问题可能是服务器未返回任何值。 Or may be some php syntax issues. 或者可能是一些php语法问题。 My suggestion would be can you please check the response which is returned from server. 我的建议是您可以检查服务器返回的响应。

Also are you seeing any exceptions when you click on button in console. 当您在控制台中单击按钮时,还会看到任何异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM