Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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/9/ruby-on-rails-3/4.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/JavaScript显示/隐藏复选框_Javascript_Php_Html - Fatal编程技术网

使用PHP/JavaScript显示/隐藏复选框

使用PHP/JavaScript显示/隐藏复选框,javascript,php,html,Javascript,Php,Html,我不熟悉PHP/JavaScript,我不确定我到底做错了什么。我正在尝试创建一个基于web的表单,该表单具有复选框显示/隐藏选项。我的问题是下面的代码给了我一个解析错误。如果有人能帮我指出错误,我将非常感谢你的帮助 <?php <html> <head> <title>Start</title> <?PHP $field1 = 'unchecked'; $field2 = 'unchecked'; $field3 = 'unch

我不熟悉PHP/JavaScript,我不确定我到底做错了什么。我正在尝试创建一个基于web的表单,该表单具有复选框显示/隐藏选项。我的问题是下面的代码给了我一个解析错误。如果有人能帮我指出错误,我将非常感谢你的帮助

<?php

<html>
<head>
<title>Start</title> 

<?PHP
$field1 = 'unchecked';
$field2 = 'unchecked';
$field3 = 'unchecked';
$field4 = 'unchecked';
$field5 = 'unchecked';

if (isset($_POST['Submit1'])) {
    if (isset($_POST['field1'])) {
        $field1 = $_POST['field1'];
        if ($field1 == 'net') {
            $field1 = 'checked';
            }
        }
        if (isset($_POST['field2'])) {
            $field2 = $_POST['field2'];
                if ($field2 == 'word') {
                $field2 = 'checked';
                }
            }
        if (isset($_POST['field3'])) {
            $field3 = $_POST['field3'];
            if ($field3 == 'excel') {
                $field3 = 'checked';
                }
            }
        if (isset($_POST['field4'])) {
            $field4 = $_POST['field4'];
            if ($field4 == 'web') {
                $field4 = 'checked';
                }
            }
        if (isset($_POST['field5'])) {
                $field5 = $_POST['field5'];
            if ($field5 == 'php') {
                $field5 = 'checked';
                }
            }
        }
?>
</head>

<body>
<FORM NAME ="Sign-up" METHOD ="POST" ACTION ="presurvey.php">

<P>
<Input type = 'Checkbox' Name ='field1' value ="net" 
<?PHP print $field1; ?>
    >Mobility

<P>
<Input type = 'Checkbox' Name ='field2' value="value 1" 
<?PHP print $field2; ?>
    >Value 2
<P>
<Input type = 'Checkbox' Name ='field3' value="value 2" 
<?PHP print $field3; ?>
    >Value 3

<P>
<Input type = 'Checkbox' Name ='field4' value="value 3" 
<?PHP print $field4; ?>
>Value 4

<P>
<Input type = 'Checkbox' Name ='field5' value="value 4" 
<?PHP print $field5; ?>
>Name

<P>

<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Submit">

</FORM>
</body>
</html>

echo <script type="text.javascript"> 

// called onclick of checkbox
function toggleSub(box, id) {
    // get reference to related content to display/hide
    var el = document.getElementById(id);

    if ( box.checked ) {
        el.style.display = 'block';
    } else {
        el.style.display = 'none';
    }
}
</script>;

?>

>价值2

>价值4


开始

>价值2

>价值4


在哪里可以找到Excel、word等值??
<html>
<head>
<title>Start</title> 

<?php

$field1 = 'unchecked';
$field2 = 'unchecked';
$field3 = 'unchecked';
$field4 = 'unchecked';
$field5 = 'unchecked';

if (isset($_POST['Submit1'])) {
    if (isset($_POST['field1'])) {
        $field1 = $_POST['field1'];
        if ($field1 == 'net') {
            $field1 = 'checked';
            }
        }
        if (isset($_POST['field2'])) {
            $field2 = $_POST['field2'];
                if ($field2 == 'word') {
                $field2 = 'checked';
                }
            }
        if (isset($_POST['field3'])) {
            $field3 = $_POST['field3'];
            if ($field3 == 'excel') {
                $field3 = 'checked';
                }
            }
        if (isset($_POST['field4'])) {
            $field4 = $_POST['field4'];
            if ($field4 == 'web') {
                $field4 = 'checked';
                }
            }
        if (isset($_POST['field5'])) {
                $field5 = $_POST['field5'];
            if ($field5 == 'php') {
                $field5 = 'checked';
                }
            }
        }
?>
</head>

<body>
<FORM NAME ="Sign-up" METHOD ="POST" ACTION ="presurvey.php">

<P>
<Input type = 'Checkbox' Name ='field1' value ="net" 
<?php print $field1; ?>
    >Mobility

<P>
<Input type = 'Checkbox' Name ='field2' value="value 1" 
<?php print $field2; ?>
    >Value 2
<P>
<Input type = 'Checkbox' Name ='field3' value="value 2" 
<?php print $field3; ?>
    >Value 3

<P>
<Input type = 'Checkbox' Name ='field4' value="value 3" 
<?php print $field4; ?>
>Value 4

<P>
<Input type = 'Checkbox' Name ='field5' value="value 4" 
<?php print $field5; ?>
>Name

<P>

<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Submit">

</FORM>
</body>
</html>

<script type="text/javascript"> 

function toggleSub(box, id) {
    // get reference to related content to display/hide
    var el = document.getElementById(id);

    if ( box.checked ) {
        el.style.display = 'block';
    } else {
        el.style.display = 'none';
    }
}
</script>;