0

Hi Bootstrap buttons are very beautiful, but How could I get the value which the user click or enter?

ie. for the check boxes.

<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>

If I use the PHP, could I get the values to the next page? How?

4

2 回答 2

0

have you tried give same same to checkboxex and handle it at phpside? like;

HTML

<form .....
    <label class="checkbox inline">
      <input name="mycheckboxes[]" type="checkbox" id="inlineCheckbox1" value="option1"> 1
    </label>
    <label class="checkbox inline">
      <input name="mycheckboxes[]" type="checkbox" id="inlineCheckbox2" value="option2"> 2
    </label>
    <label class="checkbox inline">
      <input name="mycheckboxes[]" type="checkbox" id="inlineCheckbox3" value="option3"> 3
    </label>

PHP

var_dump($_POST);
于 2013-04-01T23:49:00.250 回答
0

给它一个有意义的名字。对于这样的表格:

<input type="checkbox" name="gender" id="inlineCheckbox1" value="male"> male
<input type="checkbox" name="gender" id="inlineCheckbox1" value="female"> female

您只需执行以下操作:

if (isset($_POST['gender']))
{
    $user_gender = $_POST['gender']; // would equal either "male" or "female"
}

或捷径:

$user_gender = isset($_POST['gender']) && $_POST['gender'] == "male"  ? "male" : "female";

快乐编码。希望这可以帮助!

于 2013-04-02T00:11:58.453 回答