Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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
Php 输入提交按钮的可见性设置_Php_Html - Fatal编程技术网

Php 输入提交按钮的可见性设置

Php 输入提交按钮的可见性设置,php,html,Php,Html,我用下面的代码做了一个小实验,它有一个包含输入提交按钮的表单。我发现,如果我将input submit按钮的可见性设置为visible,那么当我隐藏表单时,它将不会隐藏。但是,如果我将input submit按钮的可见性设置为其他任何内容,例如空字符串或类似“abcd”的内容,那么当我隐藏表单时,它将隐藏。有人能给我解释一下吗?非常感谢 <!DOCTYPE html> <html> <head> <style type="tex

我用下面的代码做了一个小实验,它有一个包含输入提交按钮的表单。我发现,如果我将input submit按钮的可见性设置为visible,那么当我隐藏表单时,它将不会隐藏。但是,如果我将input submit按钮的可见性设置为其他任何内容,例如空字符串或类似“abcd”的内容,那么当我隐藏表单时,它将隐藏。有人能给我解释一下吗?非常感谢

<!DOCTYPE html>

<html>
    <head>
        <style type="text/css">
            .sub
            {
                width: 100px;
                height: 40px;
                background-color: #1eaa28;
                cursor: pointer;
            }
        </style>
    </head>
    <body>
        <form method="POST" id="TestForm">
            <input type="submit" value="" id="TestButton" class="sub" style="visibility: abcd">
        </form>
    </body>
</html>

<?php                       
    echo "<script type='text/javascript'>TestForm.style.visibility = \"hidden\"</script>";              

    // button hides if style="visibility: "

    // button does not hide if style="visibility: visible"

    // button does not hide if style="visibility: abcd"

?>

.sub
{
宽度:100px;
高度:40px;
背景色:#1eaa28;
光标:指针;
}

你是说
document.TestForm.style.visibility
作为选择器吗?或者,使用
document.getElementById('TestForm').style.visibility
。尽管上面的注释是准确的,但您不应该在代码中插入标记。。。只需使用javascript(参见jQuery,它相当简单,并且有很好的选择器和hide()和show()函数)@ied3vil实际上不需要加载整个库来隐藏元素。Vanilla JS可以很好地做到这一点。你要么用php内联设置可见性,要么做脚本标记。。。这两个版本都不好,因为混合使用php和js是一种不好的做法。我过去也这样做过。您应该尽可能将php和javascript分开。。。