dongyuedaochen8415 2013-10-04 13:49
浏览 108


This is an extended question from: Get $_POST from multiple checkboxes

I am trying to get the labels of each checked checkbox, then display it as such:

"Sales | Engineering" (without the quotes)

Or if only one checkbox was selected:


HTML (myform.html):

<!DOCTYPE html>
<form name='myform' method='post' action='result.php'>
<label for='sales'>Sales</label>
<input type='checkbox' name='loc_chks[]' id='sales' value='Sales' /><br/>

<label for='insideSales'>Inside Sales</label>
<input type='checkbox' name='loc_chks[]' id='insideSales' value='Inside Sales' /><br/>

<label for='engineering'>Engineering</label>
<input type='checkbox' name='loc_chks[]' id='engineering' value='Engineering' /><br/>

<label for='fieldService'>Field Service</label>
<input type='checkbox' name='loc_chks[]' id='fieldService' value='Field Service' /><br/>

<label for='production'>Production</label>
<input type='checkbox' name='loc_chks[]' id='production' value='Production' /><br/>

<label for='warehouse'>Warehouse</label>
<input type='checkbox' name='loc_chks[]' id='warehouse' value='Warehouse'/><br/>
<input type='submit' id='subBtn' value='Submit'/>


PHP (result.php):

 <!DOCTYPE html>
          if(!empty($_POST["loc_chks"]) and is_array($_POST["loc_chks"])) {
            echo implode(' | ',$_POST["loc_chks"]);
          } else { echo "we have a loser";}


*Edited - the "if" statement in the php file always returns false even if multiple checkboxes are checked

  • 写回答



      相关推荐 更多相似问题


      • ¥15 如何在linux服务器做视频静态资源访问接口
      • ¥15 Python Xpath对<em>标签的爬取结果变成了- -(关键词-Xpath)
      • ¥15 el-cascader懒加载模式选中单选框加载下层无数据问题
      • ¥15 promql 参数怎么忽视大小写查询
      • ¥50 swift使用textkit读取大文本文件速度慢的问题
      • ¥20 统信linux360企业浏览器 如何配置扩展程序?(图形界面我知道)
      • ¥100 c/c++实现DoubleArrayTrie
      • ¥15 在开发/迭代一款企业信息软件时会耗费你们多长时间?
      • ¥15 如果可以为你提供一款定制化的企业软件,您最希望在哪个板块实现定制化?
      • ¥30 关于#网络安全#的问题:非对称加密验证