Selecting multiple buttons in a form using Bootstrap - html

I have a set of buttons that form a selection as part of my form.
The code is below:
<div class="form-group">
<div>
<h4>Extras</h4>
</div>
<div class="radio-inline">
<input type="button" class="btn btn-default inline" name="extra" value="Garden" >
<input type="button" class="btn btn-default inline" name="extra" value="Balcony">
<input type="button" class="btn btn-default inline" name="extra" value="Parking">
</div>
</div>
However, I want to make the options not mutually exclusive i.e. you can select both 'Garden' and 'Balcony' - and I'd like to retain the button styling.
Can anyone help with this?
EDIT: Ok - got something weird going on now - Got this code.
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="checkbox" name="garden" checked=""> Garden
</label>
<label class="btn btn-default">
<input type="checkbox"> Balcony
</label>
<label class="btn btn-default">
<input type="checkbox"> Parking
</label>
</div>
When I use bootply the multiple selection user feature works great - when I add it to my page - its not working - does anyone have any idea why it may be? Below is the whole page
<div class="container">
<div class="row">
<div class="col-md-12"><h2>This is the header</h2></div>
</div>
<div class="row">
<div class="col-md-8">
<h2>Hello world!</h2>
<form d="multiform" role="form" action="listing.php" method="post" enctype="multipart/form-data">
<div><h4>Listing Type</h4></div>
<div class="radio">
<input type="button" class="btn btn-default" value="For Sale" >
<input type="button" class="btn btn-default inline" name="list_type" value="For Rent">
<input type="button" class="btn btn-default inline" name="list_type" value="Flat Share">
</div>
<div class="form-group">
<label for="text">Title</label>
<input class= "form-control" type="text" name="text">
</div>
<div class="form-group">
<label for="desc">Description</label>
<textarea class= "form-control" name="desc" rows="5"></textarea>
</div>
<!nested columns in the first one!>
<div class="col-md-6">
<div class="form-group">
<label for="total_beds">Total Bedrooms</label>
<select class="form-control" name="total_beds">
<option>Total Bedrooms</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="pets">Pets</label>
<select class="form-control" name="pets">
<option>Pets OK?</option>
<option>Yes</option>
<option>No</option>
</select>
</div>
<p>This is another p</p>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="postcode">Postcode (for Maps)</label>
<input type="text" class="form-control" name="postcode" placeholder="Post Code">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<div><h4>Extras</h4>
<div class="checkbox">
<input type="button" class="btn btn-default inline" name="extra" value="Garden" >
<input type="button" class="btn btn-default inline" name="extra" value="Balcony">
<input type="button" class="btn btn-default inline" name="extra" value="Parking">
</div>
</div>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="checkbox" name="garden" checked=""> Garden
</label>
<label class="btn btn-default">
<input type="checkbox"> Balcony
</label>
<label class="btn btn-default">
<input type="checkbox"> Parking
</label>
</div>
</div>
</form>
</div>
<div class="col-md-4">Hello world Right! </div>
</div><! closes container!>

See the JavaScript buttons section of the Bootstrap documentation, and look at checkbox buttons:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="checkbox" checked> Option 1 (pre-checked)
</label>
<label class="btn btn-primary">
<input type="checkbox"> Option 2
</label>
<label class="btn btn-primary">
<input type="checkbox"> Option 3
</label>
</div>

Related

Layout form input bootstrap

I have a problem with layout bootstrap. I want the search button to remain at the end of the line.
Here is my code:
<form id="frmTest" class="form-inline">
<div class="form-group">
<input type="text" name="full_name" class="form-control" id="full_name" placeholder="Name"/>
</div>
<div class="form-group">
<div class="input-group date date-picker" data-date-format="dd-mm-yyyy">
<input type="text" name="start_date" class="form-control" readonly id="start_date" size="8" placeholder="From(Date)">
<span class="input-group-btn">
<button class="btn default" type="button">
<i class="fa fa-calendar"></i>
</button>
</span>
</div>
</div>
<div class="form-group">
<div class="input-group date date-picker" data-date-format="dd-mm-yyyy">
<input type="text" name="end_date" class="form-control" readonly id="end_date" size="8" placeholder="To(Date)">
<span class="input-group-btn">
<button class="btn default" type="button">
<i class="fa fa-calendar"></i>
</button>
</span>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary black" onClick="clearForm(event);" id="btn-reset" >clear</button>
</div>
</form>
<button class="btn btn-warning " id="btn-search">Search</button> //this not part form input
output:
I want the layout like this:
How can this resolved?
1)Place search button into the form.
2) If you don't want to place the search button into the form, then try the below code.
Just, make the form inline.
form {
display: inline;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<form id="frmTest" class="form-inline">
<div class="form-group">
<input type="text" name="full_name" class="form-control" id="full_name" placeholder="Name" />
</div>
<div class="form-group">
<div class="input-group date date-picker" data-date-format="dd-mm-yyyy">
<input type="text" name="start_date" class="form-control" readonly id="start_date" size="8" placeholder="From(Date)">
<span class="input-group-btn">
<button class="btn default" type="button">
<i class="fa fa-calendar"></i>
</button>
</span>
</div>
</div>
<div class="form-group">
<div class="input-group date date-picker" data-date-format="dd-mm-yyyy">
<input type="text" name="end_date" class="form-control" readonly id="end_date" size="8" placeholder="To(Date)">
<span class="input-group-btn">
<button class="btn default" type="button">
<i class="fa fa-calendar"></i>
</button>
</span>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary black" onClick="clearForm(event);" id="btn-reset">clear</button>
</div>
</form>
<button class="btn btn-warning " id="btn-search">Search</button>
Note: View the output in full page mode.

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>

Add space between input and button in bootstrap

I am using bootstrap 3 and have this HTML:
<body>
<div class="container body-content">
<div class="row">
<div class="col-lg-6">
<label class="control-label" for="parameterValue">sdsd</label>
<div class="input-group">
<input class="form-control" type="text" name="parameterValue" placeholder="Enter a value..." />
<span class="input-group-btn"><button class="btn btn-default btn-success">Update</button></span>
</div>
<label class="control-label" for="parameterValue">sdsd</label>
<div class="input-group">
<input class="form-control" type="text" name="parameterValue" placeholder="Enter a value..." />
<span class="input-group-btn"><button class="btn btn-default btn-success">Update</button></span>
</div>
<button class="btn btn-default btn-primary" data-bind="click: $root.completeStep">Complete Step</button>
</div>
</div>
</div>
</body>
fiddle
I want the final button to be spaced away vertically from the input-group div and not touching it.
An example I found using a form has the button spaced out: fiddle
and this is how I'd like my button. How can I get that?
Simply wrap each pair of <label> and <div class="input-group"> by a <div> having .form-group class. (Or just wrap the last pair if needed so)
The reason is that twitter bootstrap applies a margin-bottom of 15px to .form-group. You could also do this manually by giving the <button> a top margin or giving the last input a bottom margin.
EXAMPLE HERE
<div class="container body-content">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label class="control-label" for="parameterValue">sdsd</label>
<div class="input-group">
<input class="form-control" type="text" name="parameterValue" placeholder="Enter a value..." />
<span class="input-group-btn"><button class="btn btn-default btn-success">Update</button></span>
</div>
</div>
<div class="form-group">
<label class="control-label" for="parameterValue">sdsd</label>
<div class="input-group">
<input class="form-control" type="text" name="parameterValue" placeholder="Enter a value..." />
<span class="input-group-btn"><button class="btn btn-default btn-success">Update</button></span>
</div>
</div>
<button class="btn btn-default btn-primary" data-bind="click: $root.completeStep">Complete Step</button>
</div>
</div>
</div>

Placing a checkbox in an input addon bootstrap

I am trying to place a checkbox within an input group addon whilst using a bootstrap 3 form.
The checkbox is to show password on a sign in form.
<form class="form-signin">
<h1 class="form-signin-heading" align="center"><strong>Owner Gateway</strong></h1>
<input type="text" class="form-control" placeholder="Username" required autofocus></input>
<div class="wrapper">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Password"/>
<span class="input-group-addon">Show</span>
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
<button class="btn btn-lg btn-primary btn-block" id="new-btn" type="submit">Stay Logged in</button>
</div>
</form>
If anyone could help, I would be very grateful.
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Password"/>
<span class="input-group-addon"><input type="checkbox"> Show</span>
</div>
Just try simply that.

Twitter bootstrap and spans in a control-group

I am trying to implement a simple interface where I've got a series of buttons (checkboxes) which are part of a group.
I would like to split the groups so I can only have 3 per row max.
<div class="container">
<div class="control-group">
<p class="pull-left"><label class="control-label" for="Languages">Lingue</label></p>
<div class="controls">
<div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
<input type="checkbox" value="1" id="Languages_0" name="Languages" checked />
<label class="btn btn-info btn-small active" for="Languages_0">Italiano</label>
<input type="checkbox" value="2" id="Languages_1" name="Languages" checked />
<label class="btn btn-info btn-small active" for="Languages_1">Francese</label>
<input type="checkbox" value="3" id="Languages_2" name="Languages" checked />
<label class="btn btn-info btn-small active" for="Languages_2">Inglese</label>
<input type="checkbox" value="4" id="Languages_3" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_3">Spagnolo</label>
<input type="checkbox" value="5" id="Languages_4" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_4">Tedesco</label>
<input type="checkbox" value="6" id="Languages_5" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_5">Portoghese</label>
<input type="checkbox" value="7" id="Languages_6" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_6">Bulgaro</label>
<input type="checkbox" value="8" id="Languages_7" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_7">Lettone</label>
</div>
</div>
</div>
</div>
I've tried to put span3 everywhere but it seems to work only in IE.
You can see the fiddle here.
You need to break up each group of three checkboxes/labels and put them in their own div with the class name controls.
<div class="container">
<div class="control-group">
<p class="pull-left">
<label class="control-label" for="Languages">Lingue</label>
</p>
<div class="controls">
<div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
<input type="checkbox" value="1" id="Languages_0" name="Languages" checked
/>
<label class="btn btn-info btn-small active" for="Languages_0">Italiano</label>
<input type="checkbox" value="2" id="Languages_1" name="Languages"
checked />
<label class="btn btn-info btn-small active" for="Languages_1">Francese</label>
<input type="checkbox" value="3" id="Languages_2" name="Languages"
checked />
<label class="btn btn-info btn-small active" for="Languages_2">Inglese</label>/></div>
</div>
<div class="controls">
<div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
<input type="checkbox" value="4" id="Languages_3" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_3">Spagnolo</label>
<input type="checkbox" value="5" id="Languages_4" name="Languages"
/>
<label class="btn btn-info btn-small " for="Languages_4">Tedesco</label>
<input type="checkbox" value="6" id="Languages_5" name="Languages"
/>
<label class="btn btn-info btn-small " for="Languages_5">Portoghese</label>
</div>
</div>
<div class="controls">
<div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
<input type="checkbox" value="7" id="Languages_6" name="Languages" />
<label class="btn btn-info btn-small " for="Languages_6">Bulgaro</label>
<input type="checkbox" value="8" id="Languages_7" name="Languages"
/>
<label class="btn btn-info btn-small " for="Languages_7">Lettone</label>
</div>
</div>
</div>
</div>
Here's a working example on jsFiddle.