我的计划是将选择和输入都放置为输入组。总之,我希望第二个表单组看起来像第一个。这是我的代码。
<div class="row">
<div class="col-lg-5 col-xs-12">
<div class="box box-success">
<div class="box-header with-border">
<div class="box-body">
<form role="form" method="post">
<div class="box">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i>
Vendedor
</span>
<input type="text" class="form-control" name="nuevoVendedor" id="nuevoVendedor" value="oparedez" readonly>
</div>
</div>
<div class="form-group">
<div class="input-group" style="float:left;">
<select class="form-control" name="">
<option value="Factura No.">Factura No.</option>
<option value="Factura No.">Nota No.</option>
</select>
<input type="text" class="form-control" name="nuevaFactura" id="nuevaFactura" value="1-928361" readonly>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
为什么不简单地将<input>
与.input-group
放入同一<select>
:
<div class="form-group">
<div class="input-group">
<select class="form-control" name="">
<option value="Factura No.">Factura No.</option>
<option value="Factura No.">Nota No.</option>
</select>
<input type="text" class="form-control" name="nuevaFactura" id="nuevaFactura" value="1-928361" readonly>
</div>
</div>
默认情况下不需要,但您可能还需要float
的元素到left
:
.input-group > select,
.input-group > input {
float: left;
}
<div class="form-group">
<div class="input-group">
<select class="form-control" name="">
<option value="Factura No.">Factura No.</option>
<option value="Factura No.">Nota No.</option>
</select>
<input type="text" class="form-control" name="nuevaFactura" id="nuevaFactura" value="1-928361" readonly>
</div>
</div>
答案 1 :(得分:0)
Dropdown Action Another action Something else here Separated link
$(document).ready(function(e){
$( document ).on( 'click', '.bs-dropdown-to-select-group .dropdown-menu li', function( event ) {
var $target = $( event.currentTarget );
$target.closest('.bs-dropdown-to-select-group')
.find('[data-bind="bs-drp-sel-value"]').val($target.attr('data-value'))
.end()
.children('.dropdown-toggle').dropdown('toggle');
$target.closest('.bs-dropdown-to-select-group')
.find('[data-bind="bs-drp-sel-label"]').text($target.context.textContent);
return false;
});
});
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<br/>
<div class="container">
<div class="row">
<div class="form-group">
<label for="inpuFname">Text input with dropdown select</label>
<div class="input-group">
<input type="text" value="" class="form-control" name="text">
<div class="input-group-btn bs-dropdown-to-select-group">
<button type="button" class="btn btn-default dropdown-toggle as-is bs-dropdown-to-select" data-toggle="dropdown">
<span data-bind="bs-drp-sel-label">Select...</span>
<input type="hidden" name="selected_value" data-bind="bs-drp-sel-value" value="">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu" style="">
<li data-value="1"><a href="#">One</a></li>
<li data-value="2"><a href="#">Two</a></li>
<li data-value="3"><a href="#">Three</a></li>
</ul>
</div>
</div>
</div>
Check the hidden field for values!
</div>
</div>
$(document).ready(function(e){
$( document ).on( 'click', '.bs-dropdown-to-select-group .dropdown-menu li', function( event ) {
var $target = $( event.currentTarget );
$target.closest('.bs-dropdown-to-select-group')
.find('[data-bind="bs-drp-sel-value"]').val($target.attr('data-value'))
.end()
.children('.dropdown-toggle').dropdown('toggle');
$target.closest('.bs-dropdown-to-select-group')
.find('[data-bind="bs-drp-sel-label"]').text($target.context.textContent);
return false;
});
});
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!-- Based on: http://bootsnipp.com/snippets/featured/multiple-control-input-group -->
<br/>
<div class="container">
<div class="row">
<div class="form-group">
<label for="inpuFname">Text input with dropdown select</label>
<div class="input-group">
<input type="text" value="" class="form-control" name="text">
<div class="input-group-btn bs-dropdown-to-select-group">
<button type="button" class="btn btn-default dropdown-toggle as-is bs-dropdown-to-select" data-toggle="dropdown">
<span data-bind="bs-drp-sel-label">Select...</span>
<input type="hidden" name="selected_value" data-bind="bs-drp-sel-value" value="">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu" style="">
<li data-value="1"><a href="#">One</a></li>
<li data-value="2"><a href="#">Two</a></li>
<li data-value="3"><a href="#">Three</a></li>
</ul>
</div>
</div>
</div>
Check the hidden field for values!
</div>
</div>