简体   繁体   English

Twitter Bootstrap HTML表单单选按钮不适用于PHP POST

[英]Twitter Bootstrap HTML form radio button not working with PHP POST

For some reason the radio button value from my form is not being passed to the form PHP script on some web browsers when using the Twitter Bootstrap framework. 由于某些原因,在使用Twitter Bootstrap框架时,某些Web浏览器上的表单中的单选按钮值未传递到表单PHP脚本。

Form: 形成:

<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>

This the PHP code for collecting the variable is one simple line: 这是用于收集变量的PHP代码,它很简单:

$option = $_POST['opt'];

This method works absolutely fine with Chrome but doesn't work in IE, Firefox or Opera. 这种方法在Chrome上绝对可以正常使用,但在IE,Firefox或Opera中却无法使用。

Can anyone shed any light on this? 谁能对此有所启示?

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): 使用以下代码(注意我添加了一个提交按钮),该代码在FF中对我来说正常工作:

<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); print_r($ _ POST);的结果

Array ( [q] => [opt] => 1 [submit] => submit ) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM