【发布时间】:2023-04-02 22:44:01
【问题描述】:
我们有一个跨多个页面的表单,该表单充满了复选框和单选按钮。要求是当用户浏览表单的多个页面时,用户应该能够在按下表单提交按钮之前看到他已经选择的复选框和单选按钮。
我正在复制用于在表单中生成复选框的代码段 - 这只是示例代码。
<form action="car_model.php" method="post" name="car_form" id="car_form">
$q10 = "SELECT ...
$r10 = mysqli_query ($dbc, $q10);
if (mysqli_num_rows($r10) > 0) {
while ($row10 = mysqli_fetch_array($r10, MYSQLI_ASSOC))
{
echo '<p class="normal_text"><input type="checkbox" name="model_selection[]" value="' . $row10['model_id'] . '" onclick="return KeepCount()"; />' . $row10['car_model_name'] . '</p></br>';
}
}
</form>
if ($pages > 1) {
echo '<br /><p>';
// Determine what page the script is on:
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo '<a href="car_model.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="car_model.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
}
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="car_model.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>';
}
我知道 JQuery 是一个很好的工具——如何使用它?
【问题讨论】:
-
将它们添加到会话中?