2
I need to put two selects
within a single div
, one aligned to the left, and the other to the right.
I’ve tried using CSS by creating a class to apply to each select
, but it didn’t work:
select.left {
text-align: left;
}
select.right {
text-align: right;
}
I’m using the twitter-bootstrap + Flat-ui
, so I’ve already created the checkable example below and the FIDDLE with these libraries:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://designmodo.github.io/Flat-UI/docs/assets/js/application.js"></script>
<link href="http://designmodo.github.io/Flat-UI/dist/css/flat-ui.min.css" rel="stylesheet"/>
<script src="http://designmodo.github.io/Flat-UI/dist/js/flat-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-8">
<label class="control-label" for="cest"> Estado:
<br/>
<select name="Test" id="cest" class="select select-primary select-exemploa right" data-toggle="select"></select>
</label>
<label class="control-label" for="Ccid"> Cidade:
<br/>
<select class="select select-primary select-exemploa left" name="Tcid" id="Ccid" data-toggle="select"></select>
</label>
</div>
Note: they have to stay the same div
because otherwise the script that populates the selects
do not find the city after you have chosen the state. In this link you have a fiddle with the plugin.
So, but I can not split into two columns, because otherwise the plugin does not populate the second select... here is a fiddle with the plugin, take a look...
– gustavox
So I’m using class because I use two sets of these
selects
. If it was just one, you could use it forid
no problem, but with two it has to be by class, only then I can not use adiv
for each (what would be the ideal btw, even for responsiveness)... Later I think about using another type (of autocomplete), but for now it will have to be this one... Is there no way? Thanks.– gustavox
@Gustavox you have jQuery, just use: http://jsfiddle.net/sgecadth/19/
– KaduAmaral
In fact even your code is working correctly: http://jsfiddle.net/sgecadth/21/ only that you placed it inside the
window.load
and Jsfiddle was already doing it.– KaduAmaral
That’s it! I still took the
#Cform
, and I just left$('.classdivcolb')
at the suggestion of the ID and was perfect. Thanks!– gustavox