I'm trying to display a text input inline with a dropdown button. I can't figure out how to do this though. Here's the HTML I've tried (I've put all of it on a single line with no results):
<div class="input-append">
<input type="text" placeholder="foo" class="input-mini">
<div class="btn-group">
<a id="amount_type" class="btn dropdown-toggle" data-toggle="dropdown" href="#">10<span class="caret"></span></a>
<ul id="amount_type_options" class="dropdown-menu">
<li class="selected"><a href="#">10</a></li>
<li><a href="#">100</a></li>
<li><a href="#">1000</a></li>
</ul>
</div>
</div>
Is this possible?
Thank you
This question is related to
html
twitter-bootstrap
textinput
This is the code for Bootstrap with input search dropdown. I search a lot then i try its in javascript and html with bootstrap,
HTML Code :
<div class="form-group">
<label class="col-xs-3 control-label">Language</label>
<div class="col-xs-7">
<div class="dropdown">
<button id="mydef" class="btn dropdown-toggle" type="button" data-toggle="dropdown" onclick="doOn(this);">
<div class="col-xs-10">
<input type="text" id="search" placeholder="search" onkeyup="doOn(this);"></input>
</div>
<span class="glyphicon glyphicon-search"></span>
</button>
<ul id="def" class="dropdown-menu" style="display:none;" >
<li><a id="HTML" onclick="mydef(this);" >HTML</a></li>
<li><a id="CSS" onclick="mydef(this);" >CSS</a></li>
<li><a id="JavaScript" onclick="mydef(this);" >JavaScript</a></li>
</ul>
<ul id="def1" class="dropdown-menu" style="display:none"></ul>
</div>
</div>
Javascript Code :
function doOn(obj)
{
if(obj.id=="mydef")
{
document.getElementById("def1").style.display="none";
document.getElementById("def").style.display="block";
}
if(obj.id=="search")
{
document.getElementById("def").style.display="none";
document.getElementById("def1").innerHTML='<li><a id="Java" onclick="mydef(this);" >java</a></li><li><a id="oracle" onclick="mydef(this);" >Oracle</a></li>';
document.getElementById("def1").style.display="block";
}
}
function mydef(obj)
{
document.getElementById("search").value=obj.innerHTML;
document.getElementById("def1").style.display="none";
document.getElementById("def").style.display="none";
}
You can use jquery and json code also as per your requirement.
This is my solution is use display: inline
Some text <div class="dropdown" style="display:inline">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>
</ul>
</div> is here
a
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>_x000D_
_x000D_
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>_x000D_
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet" />_x000D_
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />Your text_x000D_
<div class="dropdown" style="display: inline">_x000D_
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">_x000D_
Dropdown_x000D_
<span class="caret"></span>_x000D_
</button>_x000D_
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">_x000D_
<li><a href="#">Action</a>_x000D_
</li>_x000D_
<li><a href="#">Another action</a>_x000D_
</li>_x000D_
<li><a href="#">Something else here</a>_x000D_
</li>_x000D_
<li><a href="#">Separated link</a>_x000D_
</li>_x000D_
</ul>_x000D_
</div>is here
_x000D_
Search for the "datalist" tag.
<input list="texto_pronto" name="input_normal">
<datalist id="texto_pronto">
<option value="texto A">
<option value="texto B">
</datalist>
Daniel Farrell's Bootstrap Combobox does the job perfectly. Here's an example from his GitHub repository.
$(document).ready(function(){_x000D_
$('.combobox').combobox();_x000D_
_x000D_
// bonus: add a placeholder_x000D_
$('.combobox').attr('placeholder', 'For example, start typing "Pennsylvania"');_x000D_
});
_x000D_
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">_x000D_
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-combobox/1.1.8/css/bootstrap-combobox.min.css">_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-combobox/1.1.8/js/bootstrap-combobox.min.js"></script>_x000D_
_x000D_
<select class="combobox form-control">_x000D_
<option></option>_x000D_
<option value="PA">Pennsylvania</option>_x000D_
<option value="CT">Connecticut</option>_x000D_
<option value="NY">New York</option>_x000D_
<option value="MD">Maryland</option>_x000D_
<option value="VA">Virginia</option>_x000D_
</select>
_x000D_
As an added bonus, I've included a placeholder in script since applying it to the markup does not hold.
As of Bootstrap 3.x, there's an example of this in the docs here: http://getbootstrap.com/components/#input-groups-buttons-dropdowns
<div class="input-group">
<input type="text" class="form-control" aria-label="...">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Action <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div><!-- /btn-group -->
</div><!-- /input-group -->
Source: Stackoverflow.com