Send Bootstrap Button-Group value in a form with Get or Post

后端 未结 2 967
耶瑟儿~
耶瑟儿~ 2021-01-07 02:09

I created this form with bootstrap 3:

                        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 02:20

    These buttons inside 'btn-group' div, aren't doing anything useful, apart from just displaying some buttons on the screen. They are not aware of any 'selected' property (in order for the selected value to be submitted).

    Buttons are not meant to act like radio buttons, checkboxes etc. Their purpose is to perform an action when they are clicked.

    So what i recomend is to forget about button group and just add checkboxes. If you are concerned about the styling, just add this very useful library (http://icheck.fronteed.com/). I think line skin will be great for you.

    If you really want these buttons, you should write some js code (preferably jquery) and on the click event, store the selected value(s) in a hidden input that will get submitted. See here: Change a hidden input's value with jquery/javascript

提交回复
热议问题