Bootstrap Dynamic drop down on checkbox formatting - html

Still learning Bootstrap and I am trying to create an input form with check boxes where on selection of any of the check boxes a drop down appears (for that particular checkbox). The issue that I am running into is that whenever a drop down appears it shifts the other check boxes around. I would like to prevent it so that the check boxes and are fixed in place and do not shift around when the drop down appears.
Here is the HTML snippet:
<div class="container-fixed">
<div class="row">
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="cheese" >cheese
<div class="form-group"id="cheese">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="Broccoli" >Broccoli
<div class="form-group"id="Broccoli">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="Peppers" >Peppers
<div class="form-group"id="Peppers">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
Here is the jQuery:
$(document).ready(function() {
$( "input" ).click( function() {
var show = "#" + this.value
$( show ).show();
})
})

You have to use the visibility:hidden css property to hide the select boxes. This property will hide the element but it will have its space on the page.
for more description : http://www.w3schools.com/cssref/pr_class_visibility.asp
So for the above code you can do changes like this :
HTML :
<div class = "container-fixed">
<div class = "row">
<div class = "form-check col-xs-6" >
<label class = "form-check-label">
<input type = "checkbox" value = "cheese" >cheese
<div class = "form-group select-box" id = "cheese">
<label for = "Quantity">How Much?</label>
<select class = "form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class = "form-check col-xs-6" >
<label class = "form-check-label">
<input type = "checkbox" value = "Broccoli" >Broccoli
<div class = "form-group select-box" id = "Broccoli">
<label for = "Quantity">How Much?</label>
<select class = "form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class = "form-check col-xs-6" >
<label class = "form-check-label">
<input type = "checkbox" value = "Peppers" >Peppers
<div class = "form-group select-box" id = "Peppers">
<label for = "Quantity">How Much?</label>
<select class = "form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
CSS :
.select-box{
visibility: hidden;
}
jQuery :
$(document).ready(function() {
$( "input[type='checkbox']" ).click( function() {
var show = this.value
if ($(this).prop('checked')){
$( "#"+show ).css('visibility', 'visible');
}else{
$( "#"+show ).css('visibility', 'hidden');
}
})
})
JSFIDDLE : https://jsfiddle.net/8d1fnb5z/

I would look to add a new .row below the current row of checkboxes. This works as long as you can fit your checkboxes and dropdowns on one row each. Then make sure that your col classes match. So in this example i'm using .col-xs-4
http://codepen.io/partypete25/pen/VmgPVp
HTML:
<div class="container-fixed">
<div class="row">
<div class="form-check col-xs-4">
<label class="form-check-label">
<input type="checkbox" value="cheese" >cheese
</label>
</div>
<div class="form-check col-xs-4">
<label class="form-check-label">
<input type="checkbox" value="Broccoli" >Broccoli
</label>
</div>
<div class="form-check col-xs-4">
<label class="form-check-label">
<input type="checkbox" value="Peppers" >Peppers
</label>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<div class="form-group hide" id="cheese">
<label for="Quantity">How Much?</label>
<select class="form-control">
<option>regular</option>
<option>Extra</option>
</select>
</div>
</div>
<div class="col-xs-4">
<div class="form-group hide" id="Broccoli">
<label for="Quantity">How Much?</label>
<select class="form-control">
<option>regular</option>
<option>Extra</option>
</select>
</div>
</div>
<div class="col-xs-4">
<div class="form-group hide" id="Peppers">
<label for="Quantity">How Much?</label>
<select class="form-control">
<option>regular</option>
<option>Extra</option>
</select>
</div>
</div>
</div>
JAVASCRIPT:
$("input").change(function() {
var chk = "#" + this.value;
if ($(this).is(':checked')) {
$(chk).removeClass('hide');
} else {
$(chk).addClass('hide');
}
});

Related

How to Enable second dropdown based on the selection of first dropdown using jquery

I have created first dropdown which returns a bit. It is either Outbound or Inbound and based on that selection I need to enable the respective further Outbound or Inbound dropdown. It means one dropdown will remain disabled.
<div class="form-group" id="type">
<label class="control-label col-md-2">#Localiser["Outbound"] / #Localiser["Inbound"]</label>
<div class="col-md-10">
<select id="outboundInboundType" name="outboundInboundType" asp-items="#await SelectLists.OutboundInboundTypes()" class="form-control"></select>
</div>
</div>
```
Based on the selection of above code I need to open Either 'Outbound' dropdown shown below
```
<div class="form-group" id="claimOutbound">
<label asp-for="ClaimStatus" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="ClaimStatus" class="form-control" asp-items="#await SelectLists.ClaimStatusTypes()"></select>
<span asp-validation-for="ClaimStatus" class="text-danger"/>
</div>
</div>
```
Or Inbound Dropdown below
```
<div class="form-group" id="claimInbound">
<label asp-for="ClaimStatus" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="ClaimStatus" class="form-control" asp-items="#await SelectLists.InboundClaimStatusTypes()"></select>
<span asp-validation-for="ClaimStatus" class="text-danger" />
</div>
</div>
```
I need to achieve this using Jquery, I have tried using the ajax call but it is not working
Here is a working solution.
function showAproprateSelect(sender){
var val = $(sender).val();
//Hides all .select-container divs
$(".select-container").addClass("hidden-div");
//Shows the related div.
if(val == "inbound"){
$("#claimInbound").removeClass("hidden-div");
}
else if(val == "outbound"){
$("#claimOutbound").removeClass("hidden-div");
}
}
.hidden-div{
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group" id="type">
<label class="control-label col-md-2">#Localiser["Outbound"] / #Localiser["Inbound"]</label>
<br/>
<div class="col-md-10">
<select id="outboundInboundType" name="outboundInboundType" asp-items="#await SelectLists.OutboundInboundTypes()" class="form-control" onchange="showAproprateSelect(this);">
<option value="none">Select a value</option>
<option value="inbound">Inbound</option>
<option value="outbound">Outbound</option>
</select>
</div>
</div>
<br/>
<div class="form-group select-container hidden-div" id="claimOutbound" >
<label asp-for="ClaimStatus" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="ClaimStatus" class="form-control" asp-items="#await SelectLists.ClaimStatusTypes()">
<option value="select">Outbound value</option>
</select>
<span asp-validation-for="ClaimStatus" class="text-danger"/>
</div>
</div>
<br/>
<div class="form-group select-container hidden-div" id="claimInbound">
<label asp-for="ClaimStatus" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="ClaimStatus" class="form-control" asp-items="#await SelectLists.InboundClaimStatusTypes()">
<option value="select">Inbound value</option>
</select>
<span asp-validation-for="ClaimStatus" class="text-danger" />
</div>
</div>
You can try this code:
var boundType= function () {
if ($("#outboundInboundType").find(":selected").val() == `your desired value`) {
$("#claimOutbound > select").prop('disabled', false);
}
else {
$("#claimOutbound > select").prop('disabled', true);
}
};
$(boundType);
$("#outboundInboundType").change(boundType);

HTML/vue.js - disable select list when checked

I have a form with the field "age". There are two possible scenarios: either I check the "unknow" box and then you can't enter/select an age (in other words, this option should be disabled) or the box is not checked, and then you can enter the age. However, I can't do the first scenario at all. Here is my code:
<div class="row mb-3">
<label for="age" class="col-sm-2 col-form-label"> Age </label>
<div class="col-sm-10">
<input type="number"class="col-sm-3 col-form-control" min="0" max="120" step="1" id="age">
</div>
<div class="row mb-3">
<label class="col-sm-1 col-form-check-label"> Unknow </label>
<input class="form-check-input" type="checkbox" id="check1" name="option1" value="something">
</div>
</div>
Is it possible to do this with vue.js? Thank you in advance!!
Here is your first scenario.
const checkBox = document.getElementById('check1')
const input = document.getElementById('age')
checkBox.addEventListener('change', (event) => {
if (event.currentTarget.checked) {
input.disabled = true
} else {
input.disabled = false
}
})
<div class="row mb-3">
<label for="age" class="col-sm-2 col-form-label"> Age </label>
<div class="col-sm-10">
<input type="number" class="col-sm-3 col-form-control" min="0" max="120" step="1" id="age">
</div>
<div class="row mb-3">
<label class="col-sm-1 col-form-check-label"> Unknow </label>
<input class="form-check-input" type="checkbox" id="check1" name="option1" value="something">
</div>
</div>
You can do with both. The thing is, you should understand how it works in plain JavaScript first before jumping to any kind of JavaScript framework, hope that makes sense
const app = new Vue({
el: "#app",
data() {
return {
checkedStatus: false,
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div class="row mb-3" id="app">
<label for="age" class="col-sm-2 col-form-label"> Age </label>
<div class="col-sm-10">
<input type="number" class="col-sm-3 col-form-control" min="0" max="120" step="1" id="age" :disabled="checkedStatus">
</div>
<div class="row mb-3">
<label class="col-sm-1 col-form-check-label"> Unknow </label>
<input class="form-check-input" type="checkbox" id="check1" name="option1" value="something" #change="checkedStatus=!checkedStatus">
</div>
</div>

required and checked input tags not working in an Angular component

I'm making a sign up form for a web application, and I'm trying to make certain fields required, and one of the radio buttons pre-checked, but neither the "required" nor the "checked" input tags seem to have any effect. I am using Firefox as my browser and bootstrap css classes.
When I take out all the Angular related code (the ngForm, ngModel and *ngIf error messages) and just open it in the browser like pure html/css, the radio button becomes checked and the required field do act as they should. So I must have made some logical mistake with my Angular code, which i am fairly new to.
<div class="container">
<div class="row">
<div class="col-12">
<h1>Registration</h1>
</div>
</div>
<form #regForm="ngForm" method="POST" (ngSubmit)= "registrate()">
<div class="row">
<div class="col-sm-4">
<label for="firstName">*First name:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="firstName"
class="form-control"
name = "firstName"
#firstName = "ngModel"
[(ngModel)] = "user.firstName"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="lastName">*Last name:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="lastName"
class="form-control"
name = "lastName"
#lastName = "ngModel"
[(ngModel)] = "user.lastName"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="email">*E-mail:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="email"
class="form-control"
name = "email"
#email = "ngModel"
[(ngModel)] = "user.email"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="occupation">Occupation:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="occupation"
class="form-control"
name = "occupation"
[(ngModel)] = "user.occupation"/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="username">*Username:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="username"
class="form-control"
name = "username"
#username = "ngModel"
[(ngModel)] = "user.username"
required/>
</div>
</div>
<div class="row" *ngIf="regForm.submitted && nameExists">
<div class="col-sm-6" style="margin: auto">
<p style="color: red; text-align: center">The desired username already exists</p>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="password1">*Password:</label>
</div>
<div class="col-sm-8">
<input
type="password"
id="password1"
class="form-control"
name = "password1"
pattern="^(?=.{8,12}$)(?!.*(\S)\1{2})(?=.*[A-Z])(?=.*[a-z]{3})(?=.*\d)(?=.*[^a-zA-Z0-9])([a-zA-Z]\S*)$"
#password1 = "ngModel"
[(ngModel)] = "user.password1"
required/>
</div>
</div>
<div class="row" *ngIf="regForm.submitted && password1?.errors.pattern">
<div class="col-sm-6" style="margin: auto">
<p style="color: red; text-align: center">Bad password!</p>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="password2">*Re-enter your password:</label>
</div>
<div class="col-sm-8">
<input
type="password"
id="password2"
class="form-control"
name = "password2"
#password2 = "ngModel"
[(ngModel)] = "checkPassword"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label>Gender:</label>
</div>
<div class="col-sm-4">
<label for="male">male:</label>
<input
type="radio"
name="gender"
id="male"
value="male"
checked
#gender1 = "ngModel"
[(ngModel)] = "user.gender"/>
</div>
<div class="col-sm-4">
<label for="female">женски:</label>
<input
type="radio"
name="gender"
id="female"
value="female"
#gender2 = "ngModel"
[(ngModel)] = "user.gender"/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="idNumber">*ID number:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="idNumber"
class="form-control"
name = "idNumber"
#idNumber = "ngModel"
[(ngModel)] = "user.idNumber"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="question">*Security question:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="question"
class="form-control"
name = "question"
#question = "ngModel"
[(ngModel)] = "user.question"
required/>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<label for="answer">*Answer:</label>
</div>
<div class="col-sm-8">
<input
type="text"
id="answer"
class="form-control"
name = "answer"
#answer = "ngModel"
[(ngModel)] = "user.answer"
required/>
</div>
</div>
<div class="row" *ngIf="regForm.submitted && (firstName.invalid || lastName.invalid || email.invalid || username.invalid || password1.invalid || password2.invalid || idNumber.invalid || question.invalid || answer.invalid)">
<div class="col-sm-6" style="margin: auto">
<p style="color: red; text-align: center">Input fields marked with * must be filled!</p>
</div>
</div>
<div class="row">
<div class="col-12" style="text-align: center">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
Note that my .ts class has these fields:
user is an object with all the fields used here,
checkPassword is a string used to match passwords,
nameExists is a boolean that is set to false,
registrate() is a function that does nothing for now.
These attributes (required and checked) in angular should be used as shown in below examples..
<input type="text" id="test2" name="test2" [(ngModel)]="test" [required]="true">
and
<input type="checkbox" [checked]="true" />
Solved the checked tag by setting the starting value of user.gender to "male". It was an empty string by default and checked tag seems to have been canceled out by it.
required tag seems to be working from Angular's perspective (ngModels are invalid), just does not have the "normal" html behavior - the inputs don't get a red border, and the usual "Please fill out this field" message doesn't show. Is this expected?

check box values as array in angularjs

I have a student registration form. I put one field named favorite color having three check box blue, green, red. user can check multiple check boxes.
now I require that when user check check boxes its values should be add in array list using ng-model.
Can Any one help me?
<div class="form-group">
<span class="col-md-1 col-md-offset-2 text-center">
<i class="fa fa-bullseye bigicon"></i>
</span>
<div class="col-md-8">
<label>Favorite Colors</label>
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-model="formData.favoritecolor." value="Red"> Red
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-model="formData.favoritecolor.checked"> Blue
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-model="formData.favoritecolor.checked"> Green
</label>
</div>
</div>
</div>
above is my code:
and I want value as {favouritecolor:[red,blue,green]}
Try like this
<input type="checkbox" name="favoriteColors"
ng-click="addToList('Red')" value="Red">
and in controller:
$scope.addToList = function(color){
var index = $scope.data.favouritecolor.indexOf(color);
if(index > -1)
$scope.data.favouritecolor.splice(index,1);
else
$scope.data.favouritecolor.splice(color,index,0);
}
You can call a function on checkbox click and get the values.
JS:
function MyCtrl($scope) {
$scope.colorArray=[];
$scope.getChecked=function(color){
var index=$scope.colorArray.indexOf(color);
if(index>-1)
$scope.colorArray.splice(index,1);
else
$scope.colorArray.push(color);
$scope.temp={"favouritecolor":$scope.colorArray};
console.log($scope.temp);
}
}
HTML:
<div ng-controller="MyCtrl">
<div class="form-group">
<span class="col-md-1 col-md-offset-2 text-center"><i
class="fa fa-bullseye bigicon"></i></span>
<div class="col-md-8">
<label>Favorite Colors</label>
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-checked="colorArray.indexOf(color)>-1" value="Red" ng-click="getChecked('Red')"> Red
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-checked="colorArray.indexOf(color)>-1" ng-click="getChecked('Blue')"> Blue
</label>
<label class="checkbox-inline">
<input type="checkbox" name="favoriteColors" ng-checked="colorArray.indexOf(color)>-1" ng-click="getChecked('Green')"> Green
</label>
</div>
</div>
</div>
</div>
JS Fiddle:http://jsfiddle.net/u2c9uLmv/1/
This is one way usually used for ng-model with turning array to object then adding extra key selected which in-turn used as boolean and you can filter out data.
angular.module('app', []).controller('formController', FormController);
function FormController($scope, $filter) {
$scope.list = ['blue', 'red', 'yellow'];
$scope.colors = [];
angular.forEach($scope.list, function(data) {
$scope.colors.push({
color: data,
selected: false
});
});
$scope.showSelected = function() {
var selectedColors = $filter('filter')($scope.colors, {
selected: true
}, true);
var favouriteColors = [];
angular.forEach(selectedColors, function(data) {
favouriteColors.push(data.color);
});
console.log(favouriteColors);
};
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app">
<div class="container" data-ng-controller="formController">
<div class="row">
<div class="col-sm-12">
<form class="form-horizontal" ng-submit="showSelected()">
<div class="checkbox" data-ng-repeat="data in colors">
<label>
<input type="checkbox" data-ng-value="data.color" data-ng-model="data.selected" />{{data.color}}
</label>
</div>
<div class="form-group">
<button class="btn btn-sm btn-primary" type="submit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</body>

CSS - show div when select is checked

I'm trying to show div when one of the selects in group is checked and hide when not. I thought this should work, but it's not working.
https://jsfiddle.net/47ctm349/2/
#form-group-osobko {
display: none;
}
#odber-1:checked+#form-group-osobko {
display: block;
}
<!-- Multiple Checkboxes -->
<div class="form-group">
<label class="col-md-4 control-label" for="odber">Způsob platby</label>
<div class="col-md-4">
<div class="checkbox">
<label for="odber-0">
<input type="checkbox" name="odber" id="odber-0" value="1"> Dobírka
</label>
</div>
<div class="checkbox">
<label for="odber-1">
<input type="checkbox" name="odber" id="odber-1" value="2"> Hotově při osobním odběru
</label>
</div>
<div class="checkbox">
<label for="odber-2">
<input type="checkbox" name="odber" id="odber-2" value="3"> Platba předem na účet
</label>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group" id="form-group-osobko">
<label class="col-md-4 control-label" for="osobniodber">Místo osobního odběru</label>
<div class="col-md-4">
<input id="osobniodber" name="osobniodber" type="text" placeholder="14900,11000" class="form-control input-md">
<span class="help-block">Zadejte PSČ míst možného osobního odběru oddělená čárkou.</span>
</div>
</div>
It should work when you click the checkbox in the middle, the div id="form-group-osobko" should appear.
I was trying not to use JS with my bootstrap.
Can't get my head around what I'm doing wrong :(
Thanks.
Your solution only works, if the div to be displayed is an adjacent sibling of the checkbox input, as that is what the + selector in CSS means.
If this div is neither a sibling nor a child you can't select it with CSS and will have to use JavaScript.
#form-group-osobko {
display: none;
}
#odber-1:checked+#form-group-osobko {
display: block;
}
<!-- Multiple Checkboxes -->
<div class="form-group">
<label class="col-md-4 control-label" for="odber">Způsob platby</label>
<div class="col-md-4">
<div class="checkbox">
<label for="odber-0">
<input type="checkbox" name="odber" id="odber-0" value="1">Dobírka
</label>
</div>
<div class="checkbox">
<label for="odber-1">
<input type="checkbox" name="odber" id="odber-1" value="2">Hotově při osobním odběru
<!-- Text input-->
<div class="form-group" id="form-group-osobko">
<label class="col-md-4 control-label" for="osobniodber">Místo osobního odběru</label>
<div class="col-md-4">
<input id="osobniodber" name="osobniodber" type="text" placeholder="14900,11000" class="form-control input-md">
<span class="help-block">Zadejte PSČ míst možného osobního odběru oddělená čárkou.</span>
</div>
</div>
</label>
</div>
<div class="checkbox">
<label for="odber-2">
<input type="checkbox" name="odber" id="odber-2" value="3">Platba předem na účet
</label>
</div>
</div>
</div>
Here would be a simple jQuery solution, using just an additional class to display the div:
$('#odber-1').change(function(){
$('#form-group-osobko').toggleClass("active");
});
#form-group-osobko {
display: none;
}
#form-group-osobko.active {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Multiple Checkboxes -->
<div class="form-group">
<label class="col-md-4 control-label" for="odber">Způsob platby</label>
<div class="col-md-4">
<div class="checkbox">
<label for="odber-0">
<input type="checkbox" name="odber" id="odber-0" value="1">Dobírka
</label>
</div>
<div class="checkbox">
<label for="odber-1">
<input type="checkbox" name="odber" id="odber-1" value="2">Hotově při osobním odběru
</label>
</div>
<div class="checkbox">
<label for="odber-2">
<input type="checkbox" name="odber" id="odber-2" value="3">Platba předem na účet
</label>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group" id="form-group-osobko">
<label class="col-md-4 control-label" for="osobniodber">Místo osobního odběru</label>
<div class="col-md-4">
<input id="osobniodber" name="osobniodber" type="text" placeholder="14900,11000" class="form-control input-md">
<span class="help-block">Zadejte PSČ míst možného osobního odběru oddělená čárkou.</span>
</div>
</div>
Get it https://jsfiddle.net/47ctm349/5/
I just added Javascript, using Jquery. It works for any div anywhere:
$('#odber-0').on('change', function(){
if($('#odber-0').is(':checked'))
$("#form-group-osobko").css("display","block");
else
$("#form-group-osobko").css("display","none");
});
$('#odber-1').on('change', function(){
if($('#odber-1').is(':checked'))
$("#form-group-osobko").css("display","block");
else
$("#form-group-osobko").css("display","none");
});
$('#odber-2').on('change', function(){
if($('#odber-2').is(':checked'))
$("#form-group-osobko").css("display","block");
else
$("#form-group-osobko").css("display","none");
});
In your case no ideas with CSS.
Good luck!