【问题标题】:HTML Application "checkbox" response [duplicate]HTML 应用程序“复选框”响应 [重复]
【发布时间】:2017-04-07 10:27:14
【问题描述】:

我试图让我的“复选框”在应用程序上响应 php 文件。目前,它正在响应并为我提供应用程序页面上的所有复选框,但我需要选中的复选框。

HTML

 <div class="input-group">
     <div class="btn-group input-group form-group" data-toggle="buttons">
     <label class="btn purplebtn">
         <input type="checkbox" id="math_select" value= "math_select" /> 
         MATH  
     </label>
     <label class="btn purplebtn">
         <input type="checkbox" id="science_select" value="science_select" /> 
         SCIENCE 
     </label>
     ... (I have 6 other selections) ...
  </div>
</div>

PHP

$math_select = $_POST['math_select'];

$science_select = $_POST['science_select'];

然后我的应用程序会显示所有选项,而不是填写表单时实际选择的选项。

谢谢

【问题讨论】:

  • 复选框如果选中则返回其值,如果未选中则返回任何值。

标签: php html post checkbox


【解决方案1】:

PHP 使用 name 属性。正确的是:

<input type="checkbox" name="math_select" value= "math_select">
<input type="checkbox" name="science_select" value= "science_select">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多