简体   繁体   中英

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.

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:

$option = $_POST['opt'];

This method works absolutely fine with Chrome but doesn't work in IE, Firefox or 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):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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