2014-03-05 24 views
1

因此,這裏是我的標記引導BTN-組不改變單選按鈕

 <div class="btn-group" data-toggle="buttons"> 
    <label class="btn btn-primary"> 
     <input type="radio" name="account-type" id="optionsRadios1" value="1"> <span class="glyphicon glyphicon-user"></span> 
User</label> 
    <label class="btn btn-primary active"> 
     <input type="radio" name="account-type" id="optionsRadios2" value="2" checked> <span class="glyphicon glyphicon-eye-open"></span> 
Special user</label> 
    <label class="btn btn-primary"> 
     <input type="radio" name="account-type" id="optionsRadios2" value="3"> <span class="glyphicon glyphicon-home"></span> 
Agency</label> 
</div> 

它使得一切都很好,問題是,如果我選擇值3,也不會迎來第三單選按鈕爲選中它,或者選擇其他選項,所以當我提交表單時,選擇哪個選項並不重要,默認選中的選項將被提交。

任何提示?

回答

0

這可能是因爲你有這兩個單選按鈕

<input type="radio" name="account-type" id="optionsRadios2" value="2" checked> 

    <input type="radio" name="account-type" id="optionsRadios2" value="3"> 

改變最後id="optionsRadios3"

-1

BTN-組相同的id是一個類屬性,它不會改變的行爲你的形式。 當您需要從3個單選按鈕中選擇排除對方時,您應該對所有單選按鈕使用相同的名稱屬性,而不是單獨的ID。 我也猜測你的標籤是圍繞着這些單選按鈕的,我們只看到你的代碼的一部分,對吧?

看看this page瞭解更多關於它。

+2

這與問題無關,他的單選按鈕名稱更正確 – Cirou

1

正如有人指出,你的第三個單選按鈕ID是錯誤的。

但是,這不是問題:

真正的問題是,你正在裝載jQueryUI的自舉(我猜)後。這是一個已知的「錯誤」。只需加載jQueryUi之前的引導,一切都會運行良好