I'm trying to get input and select option inline attached with each other like this demo using Bootstrap 2.
Following Bootstrap 3 guidelines I manage to do this:
<div class="container">
<div class="col-sm-7 pull-right well">
<form class="form-inline" action="#" method="get">
<div class="form-group col-sm-5">
<input class="form-control" type="text" value="" placeholder="Search" name="q">
</div>
<div class="form-group col-sm-3">
<select class="form-control" name="category">
<option>select</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
<button class="btn btn-primary col-sm-3 pull-right" type="submit">Search</button>
</form>
</div>
</div>
It's responsive, but input and select can't be attached without some nasty css hacks. I found lot of examples with attached buttons, but that does not work with select element.
Based on spacebean's answer, this modification also changes the displayed text when the user selects a different item (just as a
<select>
would do):http://www.bootply.com/VxVlaebtnL
HTML:
Jquery:
I know this is a bit old, but I had the same problem and my search brought me here. I wanted two select elements and a button all inline, which worked in 2 but not 3. I ended up wrapping the three elements in
<form class="form-inline">...</form>
. This actually worked perfectly for me.Thanks to G_money and other suggestions for this excellent solution to input-text with inline dropdown... here's another great solution.
This works with Bootstrap 3: allowing input-text inline with a select dropdown. Here's what it looks like below...
This is how I made it without extra css or jquery:
I can't seem to make that work without hacks either, so what I did was just use the drop-down menu in place of a select box and send the info through a hidden field, like so (using your code):
http://bootply.com/93417
Jquery:
HTML:
Not sure if that will work for what you want, but it is an option for you.
I think I've accidentally found a solution. The only thing to do is inserting an empty
<span class="input-group-addon"></span>
between the<input>
and the<select>
.Additionally you can make it "invisible" by reducing its width, horizontal padding and borders:
Tested on Chrome and FireFox.