Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';t在表中不显示显示_Javascript_Html_Forms_Html Table - Fatal编程技术网

Javascript Can';t在表中不显示显示

Javascript Can';t在表中不显示显示,javascript,html,forms,html-table,Javascript,Html,Forms,Html Table,我对style.display有问题 当我更改了一个数字但它不起作用时,我想显示一个提交框(在表中) 代码如下: <head> <script> function changedisp(Section){ if (Section.style.display=="none"){ Section.style.display="" } else{ Section.style.display="none"

我对style.display有问题

当我更改了一个数字但它不起作用时,我想显示一个提交框(在表中)

代码如下:

<head>
<script>
function changedisp(Section){  
    if (Section.style.display=="none"){  
        Section.style.display=""  
    }  
    else{  
    Section.style.display="none"  
    }  
}  
function raisenumber(s,s1) {
    var x;
    x = document.getElementById(s).innerHTML;
    document.getElementById(s).innerHTML = x*1 + 1;
    changedisp(s1);
}
</script>
</head>

<body>
<table>
    <tr>
        <th><b>ID</b></th>
        <th><b>number</b></th>
        <th><b>buttoon</b></th>
        <th><b>submit</b></th>
    </tr>
    <form action="modifica_inventario.php" method="post">
    <tr>
        <td> <b id="cell1A">item number1</b></td>
        <td> <b id="cell2A">10</b></td>
        <td> <button id="cell3A" type="button" onClick=raisenumber("cell2A","cell4A")>+1</button></td>
        <td> <b id="cell4A" style="display: none;"> <input type="submit" value="submit"/></b> &nbsp </td>  
    </tr>
    <tr>
        <td> <b id="cell1B">item number1</b></td>
        <td> <b id="cell2B">10</b></td>
        <td> <button id="cell3B" type="button" onClick=raisenumber("cell2B","cell4B")>+1</button></td>
        <td> <b id="cell4B" style="display: none;"> <input type="submit" value="submit"/></b> &nbsp </td>  
    </tr>
    </form>
</table>
</body>


对此有何评论?

您需要将其明确设置为显示类型:

Section.style.display="inline";

或内联块,或块,或任何您想要的。默认情况下,A
显示为:inline,因此尝试设置为“inline”而不是空字符串“”。

您需要将试图隐藏并显示的实际元素传递给changedisp函数。在代码中,您只是传递元素的ID名称。试试这个

function raisenumber(s,s1) {
    var x;
    x = document.getElementById(s).innerHTML;
    document.getElementById(s).innerHTML = x*1 + 1;
    changedisp(document.getElementById(s1));
}
注意
changedisp(document.getElementById(s1))传递实际元素,而不仅仅是ID

Section.style.display="inline";
function raisenumber(s,s1) {
    var x;
    x = document.getElementById(s).innerHTML;
    document.getElementById(s).innerHTML = x*1 + 1;
    changedisp(document.getElementById(s1));
}