Hiding Display of the actual radio button using Bootstrap - html

I am trying to get on a form displayed using a modal class.
this radio toggle button output:
However, I am ending up getting instead where the radio button is displayed on the top and the alignment gets disturbed.
This undesirable output:
Here is my code:
<div class = "modal-body">
<form>
<div class = "row form-group">
<label class = "col-sm-2 form-check-label" for = "guestoptions"> Number of Guests</label>
<div class="form-check form-check-inline ">
<input class="form-check-input ml-3" type="radio" name="guestoptions" id="guest1" value="option1">
<label class="form-check-label" for="guest1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="guestoptions" id="guest2" value="option2">
<label class="form-check-label" for="guest2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="guestoptions" id="guest3" value="option3">
<label class="form-check-label" for="guest3">3</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="guestoptions" id="guest4" value="option4">
<label class="form-check-label" for="guest4">4</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="guestoptions" id="guest5" value="option5">
<label class="form-check-label" for="guest5">5</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="guestoptions" id="guest6" value="option6">
<label class="form-check-label" for="guest6">6</label>
</div>
</div>
<div class = "row form-group">
<label class = "col-sm-2 form-check-label" for = "section">Section</label>
<input type="radio" class="btn-check" name="section" id="option1" autocomplete="off" checked>
<label class="btn btn-success" for="option1">Non-smoking</label>
<input type="radio" class="btn-check" name="section" id="option2" autocomplete="off">
<label class="btn btn-danger" for="option2">Smoking</label>
</div>
<div class=" row form-group">
<label class = "col-sm-2" for="dateandtime">Date and Time</label>
<div class = "col"><input type="date" class="form-control" id="dateandtime" name = "Date" placeholder="Enter Date"></div>
<div class = "col"><input type="time" class="form-control" id="dateandtime" name = "Time" placeholder="Enter Time"></div>
</div>
<button class = "btn btn-secondary offset-sm-2" style = "position: relative" data-dismiss="modal">Cancel</button>
<button class = "btn btn-primary offset-sm-2 " style = "position: relative">Reserve</button>
</form>

Bootstrap v4
You can add data-toggle="buttons" to a .btn-group element and add .btn-group-toggle to style the radio inputs. Check the docs for more information.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-outline-success active">
<input
type="radio"
class="btn-check"
name="section"
id="option1"
autocomplete="off"
checked
/>
Non-smoking
</label>
<label class="btn btn-outline-danger">
<input
type="radio"
class="btn-check"
name="section"
id="option2"
autocomplete="off"
/>
Smoking
</label>
</div>
Bootstrap v5
You can use radio button groups.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="btn-group" role="group" aria-label="section preference">
<input
type="radio"
class="btn-check"
name="section"
id="option1"
autocomplete="off"
checked
/>
<label class="btn btn-outline-success" for="option1">
Non-smoking
</label>
<input
type="radio"
class="btn-check"
name="section"
id="option2"
autocomplete="off"
/>
<label class="btn btn-outline-danger" for="option2">
Smoking
</label>
</div>

Related

How to correctly align form rows one below the other in Bootstrap 4

How can I align the Section and Date and Time to be below the Number of Guests? And how can I move the buttons to be below the Date and Time text fields?
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div id="reserveTable" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg" role="content">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Reserve a Table </h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form>
<div class="form-row">
<legend class="col-form-label col-12 col-md-4">Number of Guests</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests1" value="1">
<label class="form-check-label" for="guests1">1 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests2" value="2">
<label class="form-check-label" for="guests2">2 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests3" value="3">
<label class="form-check-label" for="guests3">3 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests4" value="4">
<label class="form-check-label" for="guests4">4 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests5" value="5">
<label class="form-check-label" for="guests5">5 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests6" value="6">
<label class="form-check-label" for="guests6">6 </label>
</div>
</div>
</div>
<div class="form-row">
<legend class="col-form-label col-12 col-md-4">Section</legend>
<div class="form-check form-check-inline">
<input type="radio" class="btn-check" name="options-outlined" id="success-outlined" autocomplete="off" checked>
<label class="btn btn-outline-success" for="success-outlined">Non-Smoking</label>
<input type="radio" class="btn-check" name="options-outlined" id="danger-outlined" autocomplete="off">
<label class="btn btn-outline-danger" for="danger-outlined">Smoking</label>
</div>
</div>
<div class="form-row">
<legend class="col-form-label col-12 col-md-4">Date and Time</legend>
<div class="form-check form-check-inline">
<div class="col-4 col-md-3">
<input class="form-control" type="datetext" placeholder="Date" id="reservationDate">
</div>
<div class="col-4 col-md-3">
<input class="form-control" type="timetext" value="Time" id="reservationTime">
</div>
</div>
</div>
<div class="form-row">
<button type="button" class="btn btn-secondary btn-sm ml-auto" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary btn-sm ml-1">Reserve</button>
</div>
</form>
</div>
</form>
</div>
</div>
</div>
</div>
Here is one way you could handle a bootstrap 4 form within a modal.
It sometimes works to convert the div.modal-content to a form.modal-content element so you can utilise bootstraps modal child .modal-header, .modal-body and .modal-footer framework div elements.
There is no html 5 validation markup rules against this method (I think)... the output result is much cooler than oppose to writing the form purely inside the .modal-body div.
As long as you can handle the validation OK this way then worth playing around with this.
I have included html comments on the key opening and closing points, see comments in working demo below...
Here is fiddle version too... https://jsfiddle.net/joshmoto/2svz7u5o/
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#reserveTable">
Launch reserve table modal
</button>
<div id="reserveTable" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg" role="content">
<!-- convert modal-content div into form element -->
<form class="modal-content">
<!-- then our modal-header div -->
<div class="modal-header">
<h4 class="modal-title">Reserve a Table </h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- then our modal-body div -->
<div class="modal-body">
<!-- then our number of guests form-group -->
<div class="form-group">
<label>Number of Guests</label>
<div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests1" value="1">
<label class="form-check-label" for="guests1">1 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests2" value="2">
<label class="form-check-label" for="guests2">2 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests3" value="3">
<label class="form-check-label" for="guests3">3 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests4" value="4">
<label class="form-check-label" for="guests4">4 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests5" value="5">
<label class="form-check-label" for="guests5">5 </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="numberGuests" id="guests6" value="6">
<label class="form-check-label" for="guests6">6 </label>
</div>
</div>
</div>
<!-- then our section form-group -->
<div class="form-group">
<label>Section</label>
<div class="btn-toolbar">
<div class="btn-group btn-group-toggle btn-block" data-toggle="buttons">
<label class="btn btn-outline-success w-50">
<input type="radio" name="tableSection"> Non-Smoking
</label>
<label class="btn btn-outline-danger w-50">
<input type="radio" name="tableSection"> Smoking
</label>
</div>
</div>
</div>
<!-- then our date and time form-group -->
<div class="form-group">
<!-- form-row div for tighter gutters with multi column form fields -->
<div class="form-row">
<!-- mobile first full width then 50% on sm col width -->
<div class="col-12 col-sm-6 mb-3 mb-sm-0">
<label for="reservationDate">Date</label>
<input class="form-control" type="date" value="" id="reservationDate">
</div>
<!-- mobile first full width then 50% on sm col width -->
<div class="col-12 col-sm-6">
<label for="reservationTime">Time</label>
<input class="form-control" type="time" value="" id="reservationTime">
</div>
</div>
</div>
<!-- closing modal-body div elem -->
</div>
<!-- then our modal-footer div containing the dismiss and submit buttons -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary ml-auto" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary ml-1">Reserve</button>
</div>
<!-- closing form element for our modal-content div -->
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/js/bootstrap.min.js"></script>
In response to your last comment, IDE recommendations from me is a biased one because I have only used one in the last 8 years or more, and that is PhpStorm. It all depends on what language you are working with, I predominately use PHP so this is my IDE of choice.
I cant speak for Visual Studio or version of VS you use, tho surprising no flags (warnings, errors, etc) appear in your editor. You should not have to find an option for this, it should make you aware of any invalid html markup as you work..
..one would hope 🙏

Redirect according to Radio button after submitting form Laravel

I want to redirect to the online payment page or wallet payment page by selecting the radio button and then clicking Buy Now Button. the form will also submit when I click the buy now button.
<form name="game-form" action="submit" method="POST">
#csrf
<div class="timeline-wrapper">
<ul class="StepProgress">
<li class="StepProgress-item is-done">
<div class="bold time">STEP 1</div>
<div class="bold"><h5>Account Login</h5></div>
<div class="form-group account-type">
<select class="form-control " style="width: 100%">
<option>Default select</option>
<option value="">Gmail</option>
<option value="">Facebook</option>
</select>
<label for="exampleInputEmail1">Email Address / Facebook Number</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email/number">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
</li>
<li class="StepProgress-item is-done">
<div class="bold time">Step 2</div>
<div class="bold">
<h5>Select Recharge</h5>
</div>
<div class="form-group recharge-type">
#foreach ($games as $row)
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio1">Weekly <sup>BDT {{$row['g1']}}</sup> </label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio2">Monthly <sup>BDT {{$row['g2']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio3">100 Diamond <sup>BDT {{$row['g3']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio4" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio4">200 Diamond <sup>BDT {{$row['g4']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio5" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio5">310 Diamond <sup>BDT {{$row['g5']}}</sup> </label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio6" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio6">520 Diamond <sup>BDT {{$row['g6']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio7" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio7">620 Diamond <sup>BDT {{$row['g7']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio8" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio8">830 Diamond <sup>BDT {{$row['g8']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio9" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio9">1060 Diamond <sup>BDT {{$row['g9']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio10" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio10">2180 Diamond <sup>BDT {{$row['g10']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio11" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio11">5600 Diamond <sup>BDT {{$row['g11']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio12" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio12">$0.99 Aidrop <sup>BDT {{$row['g12']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio13" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio13">$1.99 Airdrop <sup>BDT {{$row['g13']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio14" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio14">$2.99 Airdrop <sup>BDT {{$row['g14']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio15" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio15">Level Up Pass <sup>BDT {{$row['g15']}}</sup></label>
</div>
<div class="btn-inner">
<input type="radio" class="btn-check" name="btnradio" id="btnradio16" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btnradio16">Bundle Pass <sup>BDT {{$row['g16']}}</sup></label>
</div>
#endforeach
</div>
</div>
</li>
<li class="StepProgress-item is-done">
<div class="bold time">Step 3</div>
<div class="bold">
<h5>Payment Methods</h5>
</div>
<div class="form-group payment-type">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<i class="fas fa-wallet fa-3x"></i>
<label class="form-check-label" for="inlineRadio1">GAMERSHOBBD</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
<i class="fas fa-money-check-alt fa-3x"></i>
<label class="form-check-label" for="inlineRadio2">OtherPayment</label>
</div>
</div>
</li>
</ul>
</div>
<div class="buy-btn">
<button id="top-account-submit" type="submit" class="btn btn-primary btn-lg">Buy Now</button>
</div>
</form>
This is an order page, where people will fillup the form then select the product then select the payment type.
This page will take data to the database then show those data to the next page, which will be wallet payment or online payment. I am new to Laravel. it will very helpful if anyone can give the solution.
You can do with inline js as :
<select class="form-control " style="width: 100%" onchange="this.form.submit()">
...
</select>
Or with JQuery :
$('form select').on('change', function(){
$(this).closest('form').submit();
});

bootstrap btn-group radio buttons not working on live server

I am using bootstrap btn-group class for radio buttons.They are not working on live server.My site is under development example.com .Although they work on a separate html page.
<div class="row">
<section class="col-lg-2 col-xs-3">
<label>Gender:</label></section>
<section class="col-lg-4 col-xs-8">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary control-label input-group">
<input type="radio" name="gender" id="option2" autocomplete="off" value="male">Male
</label>
<label class="btn btn-primary ">
<input type="radio" name="gender" id="option3" autocomplete="off" value="female" checked> Female
</label>
</div>
</section>
</div>
$(document).ready(function(){
$('.gender').on('click', function() {
$('.checked').removeClass('checked');
$(this).addClass('checked');
});
});
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.checked {
background-color: #286090;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<section class="col-lg-2 col-xs-3">
<label>Gender:</label>
</section>
<section class="col-lg-4 col-xs-8">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary control-label input-group gender">
<input type="radio" name="gender" id="option2" autocomplete="off" value="male">Male
</label>
<label class="btn btn-primary gender">
<input type="radio" name="gender" id="option3" autocomplete="off" value="female" checked> Female
</label>
</div>
</section>
</div>
.btn > input[type="radio"] {
display: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row">
<section class="col-lg-2 col-xs-3">
<label>Gender:</label></section>
<section class="col-lg-4 col-xs-8">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary control-label input-group">
<input type="radio" name="gender" id="option2" autocomplete="off" value="male">Male
</label>
<label class="btn btn-primary ">
<input type="radio" name="gender" id="option3" autocomplete="off" value="female" checked> Female
</label>
</div>
</section>
</div>
Add
.btn > input[type="radio"] {
display: none;
}
in your css

Twitter bootstrap btn-group doesn't allow inline text on your right?

I am trying to display 3 divs (a radio button, a button group and a select) inside a form on the same line and in that order, but I still keep failing.
I have tried this solution but didn't helped me. I really don't know if this is a common problem or I am missing something.
PICTURE
HTML
<form>
<div class="form-group row">
<div class="col-sm-2">
<label for="f-option1">
<input onClick="doSomething()" type="radio" id="f-option1" name="selector" checked>
My radio button</label>
</div>
<div class="btn-toolbar">
<label for="inputEmail3" class="col-sm-1 control-label">My group button:</label>
<div class="col-sm-2 btn-group" data-toggle="buttons">
<label class="btn btn-default"><input type="radio" name="options" id="option5">10</label>
<label class="btn btn-default"><input type="radio" name="options" id="option6">30</label>
<label class="btn btn-default"><input type="radio" name="options" id="option7">60</label>
<label class="btn btn-default"><input type="radio" name="options" id="option8">90</label>
</div>
</div>
<label for="inputEmail2" class="col-sm-1 col-form-label">My select:</label>
<div class="col-sm-2">
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
</select>
</div>
</div>
</form>
Try This.
<div class="form-group row">
<div class="col-sm-2">
<label for="f-option1">
<input onclick="doSomething()" type="radio" id="f-option1" name="selector" checked="">
My radio button</label>
</div>
<div class="btn-toolbar" "="">
<label for="inputEmail3" class="col-sm-1 control-label">My group button:</label>
<div class="col-sm-2 btn-group" data-toggle="buttons">
<label class="btn btn-default"><input type="radio" name="options" id="option5">10</label>
<label class="btn btn-default"><input type="radio" name="options" id="option6">30</label>
<label class="btn btn-default"><input type="radio" name="options" id="option7">60</label>
<label class="btn btn-default"><input type="radio" name="options" id="option8">90</label>
</div>
<label for="inputEmail2" class="col-sm-1 col-form-label">My select:</label>
<div class="col-sm-2">
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
</select>
</div>
</div>
</div>
Here is one variant of solution. You need just do inline label and dropdown list. Open full page to see result.
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="row">
<form>
<div class="col-lg-4">
<label for="f-option1">
<input onClick="doSomething()" type="radio" id="f-option1" name="selector" checked>My radio button
</label>
</div>
<div class="col-lg-4">
<div class="input-group">
<label for="inputEmail3" class="control-label">My group button:</label>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="options" id="option5">10</label>
<label class="btn btn-default">
<input type="radio" name="options" id="option6">30</label>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="input-group">
<label for="inputEmail2" class="control-label">My select:</label>
<select class="form-control" id="inputEmail2">
<option>1</option>
<option>2</option>
</select>
</div>
</div>
</form>
</div>
</div>

Bootstrap radio button "checked" flag

In case #1 works, in case #2 it do not works. Check the code bellow:
<div class="container">
<div class="row">
<h1>Radio Group #1</h1>
<label class="radio-inline">
<input name="radioGroup" id="radio1" value="option1" type="radio"> 1
</label>
<label class="radio-inline">
<input name="radioGroup" id="radio2" value="option2" checked="checked" type="radio"> 2
</label>
<label class="radio-inline">
<input name="radioGroup" id="radio3" value="option3" type="radio"> 3
</label>
</div>
<div class="row">
<h1>Radio Group #2</h1>
<label for="year" class="control-label input-group">Year</label>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input name="year" value="2011" type="radio">2011
</label>
<label class="btn btn-default">
<input name="year" value="2012" type="radio">2012
</label>
<label class="btn btn-default">
<input name="year" value="2013" checked="checked" type="radio">2013
</label>
</div>
</div>
</div>
You can see it in action here: http://bootply.com/84165
Assuming you want a default button checked.
<div class="row">
<h1>Radio Group #2</h1>
<label for="year" class="control-label input-group">Year</label>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="year" value="2011">2011
</label>
<label class="btn btn-default">
<input type="radio" name="year" value="2012">2012
</label>
<label class="btn btn-default active">
<input type="radio" name="year" value="2013" checked="">2013
</label>
</div>
</div>
Add the active class to the button (label tag) you want defaulted and checked="" to its input tag so it gets submitted in the form by default.
A javascript fix to apply the 'active' class to all labels that are parents of checked inputs:
$(':input:checked').parent('.btn').addClass('active');
insert right after
$('.btn').button();
You have to use active in the label to make it work as mentioned above. But you can use checked="checked" and it will work too. It's not necessary but it's more legible and makes more sense as it is more html format compliance.
Use active class with label to make it auto select and use checked="" .
<label class="btn btn-primary active" value="regular" style="width:47%">
<input type="radio" name="service" checked="" > Regular </label>
<label class="btn btn-primary " value="express" style="width:46%">
<input type="radio" name="service"> Express </label>
In case you want to use bootstrap radio to check one of them depends on the result of your checked var in the .ts file.
component.html
<h1>Radio Group #1</h1>
<div class="btn-group btn-group-toggle" data-toggle="buttons" >
<label [ngClass]="checked ? 'active' : ''" class="btn btn-outline-secondary">
<input name="radio" id="radio1" value="option1" type="radio"> TRUE
</label>
<label [ngClass]="!checked ? 'active' : ''" class="btn btn-outline-secondary">
<input name="radio" id="radio2" value="option2" type="radio"> FALSE
</label>
</div>
component.ts file
#Component({
selector: '',
templateUrl: './.component.html',
styleUrls: ['./.component.css']
})
export class radioComponent implements OnInit {
checked = true;
}