2

由于某种原因,在使用 Twitter Bootstrap 框架时,我的表单中的单选按钮值没有被传递到某些 Web 浏览器上的表单 PHP 脚本。

形式:

<form action="" method="post">  
<li class="stream-item stream-header search-input-item">
<span class="add-on"><i class="icon-search"></i></span>
<input type="text" class="input-xxlarge" id="appendedInputButton" autocomplete="off" name="q">
<button class="btn btn-primary" type="submit">Search</button>
</li>
</div>
<p></p>
<label class="radio">
  <input type="radio" name="opt" value="1" checked>
  Option 1
</label>
<label class="radio">
  <input type="radio" name="opt" value="2">
  Option 2
</label>

</form>

用于收集变量的 PHP 代码是一个简单的行:

$option = $_POST['opt'];

这种方法在 Chrome 上工作得很好,但在 IE、Firefox 或 Opera 中不起作用。

任何人都可以对此有所了解吗?

4

1 回答 1

0

How are you submitting the data? I cannot see a submit button.

The code works fine for me in FF using the following (notice I added a submit button):

<form action="" method="post">  
<li class="stream-item stream-header search-input-item">
<span class="add-on"><i class="icon-search"></i></span>
<input type="text" class="input-xxlarge" id="appendedInputButton" autocomplete="off" name="q">
<button class="btn btn-primary" type="submit">Search</button>
</li>
</div>
<p></p>
<label class="radio">
  <input type="radio" name="opt" value="1" checked>
  Option 1
</label>
<label class="radio">
  <input type="radio" name="opt" value="2">
  Option 2
</label>

<input type="submit" name="submit" value="submit" >

</form>

Result from print_r($_POST);

Array ( [q] => [opt] => 1 [submit] => submit ) 
于 2013-04-12T07:07:44.593 回答