Hide DIV when both switches are not checked - html

I have two collapsible switch buttons that each one collide on/off one checkbox in my form. Above the checkboxes I have a little paragraph, and I want this paragraph to hide (collide) only when both checkboxes are hidden (or main switches are off), and I don't know how to make it work. I'm developing this frontend with Bootstrap.
<label class="switch mt-2">
<input class="form-check-input" type="checkbox" role="switch" id="ds-activate" data-bs-toggle='collapse' data-bs-target='#dsForm' aria-expanded="false" aria-controls="dsForm" checked>
<div class="slider round">
</div>
</label>
<label class="switch mt-2">
<input class="fo rm-check-input" type="checkbox" role="switch" id="email-activate" data-bs-toggle='collapse' data-bs-target='#emailForm' aria-expanded="false">
<div class="slider round">
</div>
</label>
<div id="hideWhenBothSwitchOff" aria-expanded="false" class="collapse show">
<label class="form-label">MORE OPTIONSs</label>
<p>Explanation of the next options.</p>
</div>
<div id="dsForm" aria-expanded="false" class="collapse show">
<div class="form-check mt-2 mb-2">
<input class="form-check-input" type="checkbox" value="" id="all-documents">
<label class="form-check-label" for="allDocuments">
Checkbox 1 label
</label>
</div>
</div>
<div id="emailForm" aria-expanded="false" class="collapse">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="all-emails">
<label class="form-check-label" for="allEmails">
Checkbox 2 label
</label>
</div>
</div>

We can write a little JavaScript based on Bootstrap's Collapse component to achieve your goal.
// Create a collapsible from the element that should
// be shown/collapsed depending on two checkboxes.
const collapsible = new bootstrap.Collapse('#hideWhenBothSwitchOff', {
toggle: false,
});
// The checkboxes to check.
const checkboxes = [
document.getElementById('ds-activate'),
document.getElementById('email-activate'),
];
// Attach event listener to each checkbox, so we know when they
// are checked or unchecked.
checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', () => {
// If at least one checkbox is checked, show the collapsible,
// otherwise hide it.
const operation = checkboxes.some(({ checked }) => checked)
? 'show'
: 'hide';
collapsible[operation]();
});
});
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<label class="switch mt-2">
<input class="form-check-input" type="checkbox" role="switch" id="ds-activate" data-bs-toggle='collapse' data-bs-target='#dsForm' aria-expanded="false" aria-controls="dsForm" checked>
<div class="slider round">
</div>
</label>
<label class="switch mt-2">
<input class="fo rm-check-input" type="checkbox" role="switch" id="email-activate" data-bs-toggle='collapse' data-bs-target='#emailForm' aria-expanded="false">
<div class="slider round">
</div>
</label>
<div id="hideWhenBothSwitchOff" aria-expanded="false" class="collapse show">
<label class="form-label">MORE OPTIONSs</label>
<p>Explanation of the next options.</p>
</div>
<div id="dsForm" aria-expanded="false" class="collapse show">
<div class="form-check mt-2 mb-2">
<input class="form-check-input" type="checkbox" value="" id="all-documents">
<label class="form-check-label" for="allDocuments">
Checkbox 1 label
</label>
</div>
</div>
<div id="emailForm" aria-expanded="false" class="collapse">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="all-emails">
<label class="form-check-label" for="allEmails">
Checkbox 2 label
</label>
</div>
</div>

Related

Stretch the Width of dropdown in a bootstrap based on textbox

I have 2 textboxes with combined width must be always 450px
The first one has dropdown menu and the second one doesnt have it
Both textboxes form input-group
The dropdown can switch between any of these 2 anytime
I want the first dropdown width to be same as first textbox width
So even if 450px is changed to 700px in future, the width of dropdown must adapt accordingly.
<!doctype html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="dropdown selection-1d input-group" style="width:450px">
<input type="text" class=" form-control" data-bs-toggle="dropdown" value="All Fruits" aria-expanded="false" data-bs-auto-close="outside" readonly>
<input type="text" class=" form-control" value="All Fruits" aria-expanded="false">
<div class="dropdown-menu p-0">
<div class="list-group">
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit1 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit2 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit3 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit4 </label>
</div>
</div>
</div>
</body>
</html>
Here's a snippet using JS to set the width of the dropdown menu based on the data-bs-toggle sibling element.
I added a second set of drop downs with a larger width for proof of concept.
Code is commented.
// Get all dropdown menus on the page
let dropdown_menu = document.querySelectorAll('.dropdown-menu');
// foreach one
dropdown_menu.forEach(dd => {
// get the parent wrapping element
let parent = dd.parentElement;
// If that parent has the input-group class, we're in the right spot.
if (parent.classList.contains('input-group')) {
// Get the element with the data-bs-toggle attribute's width
let input_parent = parent.querySelector('[data-bs-toggle]').offsetWidth;
// set the width on the dropdown
dd.style.width = input_parent + 'px';
}
});
<!doctype html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="dropdown selection-1d input-group" style="width:450px">
<input type="text" class=" form-control" data-bs-toggle="dropdown" value="All Fruits" aria-expanded="false" data-bs-auto-close="outside" readonly>
<input type="text" class=" form-control" value="All Fruits" aria-expanded="false">
<div class="dropdown-menu p-0">
<div class="list-group">
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit1 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit2 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit3 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit4 </label>
</div>
</div>
</div>
<div class="dropdown selection-1d input-group" style="width:700px">
<input type="text" class=" form-control" data-bs-toggle="dropdown" value="Value" aria-expanded="false" data-bs-auto-close="outside" readonly>
<input type="text" class=" form-control" value="Here is a long one" aria-expanded="false">
<div class="dropdown-menu p-0">
<div class="list-group">
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit1 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit2 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit3 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit4 </label>
</div>
</div>
</div>
</body>
</html>
EDIT
Using jQuery
$(document).ready(function() {
$('.dropdown-menu').each(function() {
$prev_sib_width = $(this).prevAll('[data-bs-toggle]').outerWidth();
if ($prev_sib_width) {
$(this).width($prev_sib_width);
}
});
});
<!doctype html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="dropdown selection-1d input-group" style="width:450px">
<input type="text" class=" form-control" data-bs-toggle="dropdown" value="All Fruits" aria-expanded="false" data-bs-auto-close="outside" readonly>
<input type="text" class=" form-control" value="All Fruits" aria-expanded="false">
<div class="dropdown-menu p-0">
<div class="list-group">
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit1 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit2 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit3 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit4 </label>
</div>
</div>
</div>
<div class="dropdown selection-1d input-group" style="width:700px">
<input type="text" class=" form-control" data-bs-toggle="dropdown" value="Value" aria-expanded="false" data-bs-auto-close="outside" readonly>
<input type="text" class=" form-control" value="Here is a long one" aria-expanded="false">
<div class="dropdown-menu p-0">
<div class="list-group">
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit1 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit2 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit3 </label>
<label class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value=""> Fruit4 </label>
</div>
</div>
</div>
</body>
</html>

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 🙏

Hiding Display of the actual radio button using Bootstrap

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>

Why are the two bootstrap toggle buttons causing issue?

I have two bootstrap toggle buttons, but when I click one of them, the other is getting affected. Can you please tell me what is wrong in my code ?
<div class="row p-0 m-0">
<!-- all day event toggle -->
<div class="col-md-3">
<label for="allDayEvent">All Day Event:</label><br>
<div class="btn-group btn-group-toggle" id="AllDayEventButton" data-toggle="buttons" disable="false">
<label class="btn btn-secondary" id="allDayEventYesLbl" >
<input type="radio" name="options" id="allDayEventYes" autocomplete="off">
Yes
</label>
<label class="btn btn-secondary active " id="allDayEventNoLbl" >
<input type="radio" name="options" id="allDayEventNo" autocomplete="off">
No
</label>
</div>
</div>
<!-- all day event toggle END -->
<!-- Recurring event toggle -->
<div class="col-md-3">
<label for="recurringEvent">Recurring Event:</label><br>
<div class="btn-group btn-group-toggle" id="RecurringButton" data-toggle="buttons">
<label class="btn btn-secondary" id="recurringEventYesLbl">
<input type="radio" name="options" value="Y" id="recurringYes" autocomplete="off">
Yes
</label>
<label class="btn btn-secondary active" id="recurringEventNoLbl">
<input type="radio" name="options" value="N" id="recurringNo" autocomplete="off" checked>
No
</label>
</div>
</div>
<!-- recurring event toggle END -->
</div>
There is very simple mistake you might have overlooked. Both the inputs in both radio buttons have the same name. Inputs in same radio button should have same name, but in different groups should have different names. Just changing the names in the second group will fix it. Here is a fixed version!
<div class="row p-0 m-0">
<!-- all day event toggle -->
<div class="col-md-3">
<label for="allDayEvent">All Day Event:</label><br>
<div class="btn-group btn-group-toggle" id="AllDayEventButton" data-toggle="buttons" disable="false">
<label class="btn btn-secondary" id="allDayEventYesLbl" >
<input type="radio" name="options" id="allDayEventYes" autocomplete="off">
Yes
</label>
<label class="btn btn-secondary active " id="allDayEventNoLbl" >
<input type="radio" name="options" id="allDayEventNo" autocomplete="off">
No
</label>
</div>
</div>
<!-- all day event toggle END -->
<!-- Recurring event toggle -->
<div class="col-md-3">
<label for="recurringEvent">Recurring Event:</label><br>
<div class="btn-group btn-group-toggle" id="RecurringButton" data-toggle="buttons">
<label class="btn btn-secondary" id="recurringEventYesLbl">
<input type="radio" name="optionsTwo" value="Y" id="recurringYes" autocomplete="off">
Yes
</label>
<label class="btn btn-secondary active" id="recurringEventNoLbl">
<input type="radio" name="optionsTwo" value="N" id="recurringNo" autocomplete="off" checked>
No
</label>
</div>
</div>
<!-- recurring event toggle END -->
</div>

Resize text fields contained by Radio Button (form-check) div

I have a div which is "col-xs-8 col-xs-offset 2" that centers a form in the middle of the screen. Within this form I have two text areas and 4 radio buttons with corresponding text inputs for each. My problem is that while the text areas span the width of the container and resize appropriately when the window is resized, the inputs beside the radio button remain the same size until the browser is resized below their original length at which point they resize smaller. I would like these radio button text inputs to span in the same manner that the text areas do.
I hope this is clear enough.
<link rel="stylesheet" href="style.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<body class="container-fluid">
<div class="row">
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"</span></li>
<li>Create Quiz</li>
</ol>
<form method ="POST">
<div class="col-xs-8 col-xs-offset-2">
<fieldset class="form-group">
<legend class="text-center">
<label for="quiz_title" >Quiz Title:
</label>
</legend>
<div class="form-group">
<label for="question_text">Question</label>
<textarea class="form-control" id="explanation_text" rows="2"></textarea>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="answer" id="option1" value="radio_option1" required="required">
<label for="option1" class="form-check-label"> Answers: <a><span class="glyphicon glyphicon-pencil"></span></a>
<input class="form-control" type="text" id="option1" required="required">
</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="answer" id="option2" value="radio_option2" >
<label for="option2" class="form-check-label">
<input class="form-control" type="text" id="option2" required="required">
</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="answer" id="option3" value="radio_option3">
<label for="option3" class="form-check-label">
<input class="form-control" type="text" id="option3" required="required">
</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="answer" id="option4" value="radio_option4">
<label for="option4" class="form-check-label">
<input class="form-control" type="text" maxlength="5" id="option4" required="required">
</label>
</div>
<div class="form-group">
<label for="explanation_text">Explanation</label>
<textarea class="form-control" id="explanation_text" rows="2" placeholder="Optional..."></textarea>
</div>
</fieldset>
</div>
<div class="row">
<div class="col-xs-12">
<div class="col-xs-6">
<button type="submit" class="btn btn-primary center-block pull-right" name="question_submit"> Save Question </button>
</div>
<div class="col-xs-6">
<button type="submit" class="btn btn-primary center-block pull-left" name="quiz_submit"> Save Quiz </button>
</div>
</div>
</div>
</form>
</div>
</body>
Resizing Process:
Bootstrap has something called "Input Groups" that you might want to try. You can put the radio button next to a text input in an input group and the text input will fill up the remaining space. Look at some examples here: https://getbootstrap.com/components/#input-groups-checkboxes-radios
Here is something I put together using your code. Click on "Run code snippet" and then click "Full page" to see it in full page mode. Then you can resize the window to see how it will scale.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"</span></li>
<li>Create Quiz</li>
</ol>
<form method ="POST">
<div class="col-xs-8 col-xs-offset-2">
<fieldset class="form-group">
<legend class="text-center">
<label for="quiz_title">Quiz Title:</label>
</legend>
<div class="form-group">
<label for="question_text">Question</label>
<textarea class="form-control" id="explanation_text" rows="2"></textarea>
</div>
<label for="option1">Answers: <a><span class="glyphicon glyphicon-pencil"></span></a></label>
<div class="input-group" style="margin-bottom:10px;">
<span class="input-group-addon">
<input type="radio" name="answer" id="option1" value="radio_option1" required="required">
</span>
<input type="text" class="form-control" id="option1" required="required">
</div>
<div class="input-group" style="margin-bottom:10px;">
<span class="input-group-addon">
<input type="radio" name="answer" id="option2" value="radio_option2" required="required">
</span>
<input type="text" class="form-control" id="option2" required="required">
</div>
<div class="input-group" style="margin-bottom:10px;">
<span class="input-group-addon">
<input type="radio" name="answer" id="option3" value="radio_option3" required="required">
</span>
<input type="text" class="form-control" id="option3" required="required">
</div>
<div class="input-group" style="margin-bottom:10px;">
<span class="input-group-addon">
<input type="radio" name="answer" id="option4" value="radio_option4" required="required">
</span>
<input type="text" class="form-control" id="option4" required="required">
</div>
<div class="form-group">
<label for="explanation_text">Explanation</label>
<textarea class="form-control" id="explanation_text" rows="2" placeholder="Optional..."></textarea>
</div>
</fieldset>
</div>
<div class="row">
<div class="col-xs-12">
<div class="col-xs-6">
<button type="submit" class="btn btn-primary center-block pull-right" name="question_submit"> Save Question </button>
</div>
<div class="col-xs-6">
<button type="submit" class="btn btn-primary center-block pull-left" name="quiz_submit"> Save Quiz </button>
</div>
</div>
</div>
</form>
</div>
</div>