前端代码
<form action="search.php" method="POST">
<ul data-role="listview" data-filter="true" data-inset="true" data-filter- reveal="true" data-filter-placeholder="Search by Ingredients">
<!-- 1-10 -->
<li>
<input type="checkbox" name="search" id="ing1" class="custom" value="Passion Fruit"/>
<label for="ing1">Passion Fruit</label>
</li>
<li>
<input type="checkbox" name="search" id="ing2" class="custom" value="Banana"/>
<label for="ing2">Banana</label>
</li>
<li>
<input type="checkbox" name="search" id="ing3" class="custom" value="Mango"/>
<label for="ing3">Mango</label>
</li>
<li>
<input type="checkbox" name="search" id="ing4" class="custom" value="Orange Juice"/>
<label for="ing4">Orange Juice</label>
</li>
<li>
<input type="checkbox" name="search" id="ing5" class="custom" value="Ice"/>
<label for="ing5">Ice</label>
</li>
<li>
<input type="checkbox" name="search" id="ing6" class="custom" value="Sausages"/>
<label for="ing6">Sausages</label>
</li>
<li>
<input type="checkbox" name="search" id="ing7" class="custom" value="Bacon"/>
<label for="ing7">Bacon</label>
</li>
<li>
<input type="checkbox" name="search" id="ing8" class="custom" value="Eggs"/>
<label for="ing8">Eggs</label>
</li>
<li>
<input type="checkbox" name="search" id="ing9" class="custom" value="Beans"/>
<label for="ing9">Beans</label>
</li>
<li>
<input type="checkbox" name="search" id="ing10" class="custom" value="Milk"/>
<label for="ing10">Milk</label>
</li>
</ul>
<br />
<input type="submit" action="search.php" value="Search For Recipes">
</form>
PHP代码
if (isset($_POST['search'])) {
$choices = $_POST["search"];
$count = count($choices);
echo "<h1>" . $count . "</h1>";
echo "<h1>" . $choices . "</h1>";
}
当我选中某些框时没有返回任何内容,所以这向我表明该复选框没有被正确选中:S HELPP!!!!我正在制作一个网络应用程序可搜索列表,因此为此使用了 cod