为了账号安全,请及时绑定邮箱和手机立即绑定

如何打印所有选中的复选框?

如何打印所有选中的复选框?

PHP
大话西游666 2021-04-04 16:18:31
如果我勾选了多个复选框,我想打印所有在复选框中打勾的值。但是,它只打印我检查的第一个值。 如果我在此图像中检查超过1个复选框 它只从复选框印刷一个值预先感谢 // HTML code    <strong>IT Skills:&emsp;</strong><br><br><div class="checkboxlist"  id="skills">  <input type="checkbox" name="skills" value="Programming/Application Development" class="chk">&nbsp;Programming/Application Development&emsp;  <input type="checkbox" name="skills" value="Project Management" class="chk">&nbsp;Project Management&emsp;<br>  <input type="checkbox" name="skills" value="Helpdesk/Technical Support" class="chk">&nbsp;Helpdesk/ Technical Support&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;&nbsp;  <input type="checkbox" name="skills" value="Security/Compliance Governance" class="chk">&nbsp;Security/ Compliance Governance&emsp;<br>  <input type="checkbox" name="skills" value="Web Development" class="chk">&nbsp;Web Development&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;&nbsp;&nbsp;  <input type="checkbox" name="skills" value="Database Administration" class="chk">&nbsp;Database Administration&emsp;<br>  <input type="checkbox" name="skills" value="Business Intelligence/Analytics" class="chk">&nbsp;Business Intelligence/ Analytics&emsp;&emsp;&emsp;&emsp;&nbsp;  <input type="checkbox" name="skills" value="Mobile Applications and Device Management" class="chk">&nbsp;Mobile Applications and Device Management&emsp;<br>  <input type="checkbox" name="skills" value="Networking" class="chk">&nbsp;Networking&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;  <input type="checkbox" name="skills" value="Big Data" class="chk">&nbsp;Big Data&emsp;<br></div><span class="error_form" id="skills_error_message"></span>
查看完整描述

3 回答

?
呼唤远方

TA贡献1856条经验 获得超11个赞

我已经找到了问题的答案。事实证明,我需要在每个复选框的名称中添加[]。因此,当我在技能上添加[]时,它会打印复选框中的所有选中值。顺便说一句,感谢所有帮助过我的人。


<strong>IT Skills:&emsp;</strong><br><br>

<div class="checkboxlist"  id="skills">

  <input type="checkbox" name="skills[]" value="Programming/Application Development" class="chk">&nbsp;Programming/Application Development&emsp;

  <input type="checkbox" name="skills[]" value="Project Management" class="chk">&nbsp;Project Management&emsp;<br>

  <input type="checkbox" name="skills[]" value="Helpdesk/Technical Support" class="chk">&nbsp;Helpdesk/ Technical Support&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;&nbsp;

  <input type="checkbox" name="skills[]" value="Security/Compliance Governance" class="chk">&nbsp;Security/ Compliance Governance&emsp;<br>

  <input type="checkbox" name="skills[]" value="Web Development" class="chk">&nbsp;Web Development&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;&nbsp;&nbsp;

  <input type="checkbox" name="skills[]" value="Database Administration" class="chk">&nbsp;Database Administration&emsp;<br>

  <input type="checkbox" name="skills[]" value="Business Intelligence/Analytics" class="chk">&nbsp;Business Intelligence/ Analytics&emsp;&emsp;&emsp;&emsp;&nbsp;

  <input type="checkbox" name="skills[]" value="Mobile Applications and Device Management" class="chk">&nbsp;Mobile Applications and Device Management&emsp;<br>

  <input type="checkbox" name="skills[]" value="Networking" class="chk">&nbsp;Networking&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;

  <input type="checkbox" name="skills[]" value="Big Data" class="chk">&nbsp;Big Data&emsp;<br>

</div>

<span class="error_form" id="skills_error_message"></span>


    [skills] => Array

    (

        [0] => Web Development

        [1] => Business Intelligence/Analytics

        [2] => Networking

    )


查看完整回答
反对 回复 2021-04-23
  • 3 回答
  • 0 关注
  • 298 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信