【发布时间】:2015-03-07 05:57:18
【问题描述】:
好的,所以我在这里要做的是检查checkbox 是否已被勾选,如果有,那么我想将文本添加到名为<ul> 的类中,比如说,“确认”,所以<ul class="confirmed">,
如果尚未检查,那么我会将文本添加到名为“unconfirmed”的<ul> 类中。现在我有检查复选框是否已被确认的 php 代码(见下文),但我不知道在语句中添加什么。这是我需要帮助/指导的地方。
PHP IF 代码(检查复选框是否被勾选):
<?php
if (isset($_POST["checkbox1"])){
//write to <ul> class confirmed
} else {
//write to <ul> class unconfirmed
}
?>
这是我的 HTML 代码:
<body>
<div id="content">
<div class="jumbotron">
<h1>Is there football on Wednesday?</h1>
<h2>Yes.</h2>
</div>
<div class="alert alert-info" role="alert">Confirmed Players</div>
<ul class="list-group">
<li class="list-group-item">
<!--this is where to result of the php code would go if the checkbox is checked-->
Lorem Ipsor
</li>
</ul>
<div class="alert alert-danger" role="alert">Unconfirmed Players</div>
<li class="list-group-item">
<!--this is where to result of the php code would go if the checkbox is not checked-->
Lorem Ipsor
</li>
</div>
<!--form-->
<form action="check.php" method="POST">
<input type="checkbox" name="checkbox1">
<input type="submit"></input>
</form>
</body>
对不起,如果我似乎让你感到困惑,正如我所说,我不太好。任何帮助/指导都会很棒!
【问题讨论】:
-
这真的是关于发布 HTML“代码”...因为我觉得它不是真的。请使用正确的术语,以便我们知道您在问什么。
-
@developerwjk 是的,抱歉,我已经更新了标题。
-
对我来说,您似乎缺少插入/选择数据库部分。因此,您可以将已确认的人员存储在数据库中,并通过从数据库表中获取结果来显示他们。
-
好吧,答案很明显:没有发布按钮的帖子。您的表单只有一个复选框。任何基本的 HTML 教程,即使是糟糕的教程,都会告诉您您需要一个提交按钮。
-
您确实需要阅读 HTML 教程,而不是一遍又一遍地更新问题来创建实时教程。您提交按钮的语法错误。教程会告诉你原因。