要在提交表单后打印选定的复选框值,可以使用以下步骤:

  1. 在 HTML 中,为每个复选框添加一个唯一的名称属性。例如:
<input type="checkbox" name="checkbox1" value="value1">
<input type="checkbox" name="checkbox2" value="value2">
<input type="checkbox" name="checkbox3" value="value3">
  • 1.
  • 2.
  • 3.
  1. 在提交表单的处理脚本(例如 PHP)中,使用 $_POST$_GET 数组来获取选定的复选框值。例如:
if (isset($_POST['checkbox1'])) {
  echo "Checkbox 1 is selected: ".$_POST['checkbox1'];
}

if (isset($_POST['checkbox2'])) {
  echo "Checkbox 2 is selected: ".$_POST['checkbox2'];
}

if (isset($_POST['checkbox3'])) {
  echo "Checkbox 3 is selected: ".$_POST['checkbox3'];
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

在上述示例中,使用 isset() 函数来检查复选框是否被选中。如果复选框被选中,$_POST['checkbox1']$_POST['checkbox2']$_POST['checkbox3'] 将包含相应的复选框值。

请确保将上述代码中的 checkbox1checkbox2checkbox3 替换为你实际使用的复选框名称。

这样,在提交表单后,将打印出选定的复选框值。

希望这个回答对你有帮助。如果你有任何其他问题,请随时提问。