我有2个表单需要用来制作报告。第一个表单从一个单元格的更改中获取数据库(MariaDB)(当用户使用报表检查单元格时发生更改事件)一旦选择了单元格并且报告的详细信息,则使用这些详细信息在第二个表格提交。在那之前,一切都很完美。问题是,一旦选中它,我就无法在第一个表单的单元格上保留复选标记,因为页面是在更改时重新加载的。这使得用户认为他们没有选择任何报告。
所以,我想要做的是在从数据库获取数据后,检查第一个表单的单元格。然后,用户将点击“提交”以提交第二个表单。
亲切的问候并提前感谢您的帮助!
<form name="f1" id="form1" action="" method="post">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Select</th>
<th>Assets </th>
<th>Description </th>
<th>Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
while($agency_row = $agency_stmt->fetch(PDO::FETCH_ASSOC)){
$value1 = str_replace(' ',' ',str_pad($agency_row["agency"], -10));
$value2 = str_replace(' ',' ',str_pad($agency_row["report_name"], 70));
$formatedDate = date("D M d H:i:s Y", $agency_row["scan_end"]);
$value3 = str_replace(' ',' ',str_pad($formatedDate, 20));
echo "<tr>";
echo "<td><input onchange='f1.submit()'; type='checkbox' class='i-checks' name='agency' value='" . $value1 . ":" . $agency_row["report_name"] . ":" . $agency_row["scan_start"] . ":" . $agency_row["scan_end"] . "'></td>";
echo "<td>$value1</td>";
echo "<td>$value2</td>";
echo "<td>$formatedDate</td>";
echo "<td>$value3</td>";
echo "</tr>";
}?>
</tbody>
</table>
</form>
<form name="f2" id="form2" action="report.php" method="post">
<input type="hidden" name="agency" value="<?php echo "$agency";?>">
<input type="hidden" name="report_name" value="<?php echo "$report_name";?>">
<input type="hidden" name="scan_start" value="<?php echo "$scan_start";?>">
<input type="hidden" name="scan_end" value="<?php echo "$scan_end";?>">
<input type="hidden" value="yes" name="isPlugName">
<input type="hidden" value="yes" name="isPlugFam">
<input type="hidden" value="yes" name="isPlugInfo">
<input type="hidden" value="yes" name="isSynopsis">
<input type="hidden" value="yes" name="isDescription">
<input type="hidden" value="yes" name="isSolution">
<input type="hidden" value="yes" name="isSeeAlso">
<input type="hidden" value="yes" name="isPlugOut">
<input type="hidden" value="plugin" name="byVuln">
<input type="hidden" value="yes" name="isCvss">
<input type="hidden" value="yes" name="isVulnPub">
<input type="hidden" value="yes" name="isExploit">
<input type="hidden" value="yes" name="isCve">
<input type="hidden" value="yes" name="isBid">
<input type="hidden" value="yes" name="isOsvdb">
<input type="hidden" value="yes" name="isCert">
<input type="hidden" value="yes" name="isIava">
<input type="hidden" value="yes" name="isCWE">
<input type="hidden" value="yes" name="isMS">
<input type="hidden" value="yes" name="isSec">
<input type="hidden" value="yes" name="isEdb">
<input type="hidden" value="yes" name="isAffected">
<input type="hidden" value="yes" name="isService">
<input type="hidden" value="4" name="critical">
<input type="hidden" value="3" name="high">
<input type="hidden" value="2" name="medium">
<input type="hidden" value="1" name="low">
<input type="submit" name="submithost" value="submit">
</form>
答案 0 :(得分:0)
更改
echo "<td><input onchange='f1.submit()'; type='checkbox' class='i-checks' name='agency' value='" . $value1 . ":" . $agency_row["report_name"] . ":" . $agency_row["scan_start"] . ":" . $agency_row["scan_end"] . "'></td>"
到
$checked=(isset($_REQUEST['agency']) && $_REQUEST['agency'] == $value1) ? ' checked' : '';
echo "<td><input onchange='f1.submit()'; type='checkbox' class='i-checks' name='agency' value='" . $value1 . ":" . $agency_row["report_name"] . ":" . $agency_row["scan_start"] . ":" . $agency_row["scan_end"] . $checked ."'></td>"