Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make text input and button in same row with Bootstrap

I am using basic file upload bootstrap-fileupload.js to give me a filename and button and want to repeat the format with a text input and button.

<div class="form-group">
    <label class="control-label">Source File Name</label>
    <div class="fileupload fileupload-new" data-provides="fileupload">
        <div class="input-group">
            <div class="form-control uneditable-input"><i class="icon-file fileupload-exists"></i> 

            </div>
            <div class="input-group-btn">
                <a class="btn btn-default btn-file">
                    <span class="fileupload-new">Select file</span>
                    <span class="fileupload-exists">Change</span>
                    <input type="file" class="file-input"/></a>
                <a href="#" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Remove</a>
            </div>
        </div>
    </div>
 </div>
 <form id="frmOptions" method="post" class="form-inline span12">

 <div class="row-fluid">   
<div class="form-group">
    <label class="control-label">File Name on Upload</label>
    <div class="input-group ">
        <input id="uploadname" type="text" class="form-control">
        <a class="btn btn-default go inline">Upload to DocMan</a>
    </div>
</div>

</div>
</form>

Page hosted here https://googledrive.com/host/0B90FGJizRd-gbm1JRUswYUY5dE0/bootstrap/ I have tried variations of this with no effect. Basically I want two similar looking full width rows, each with a text field and a button. Any advice is welcome.

like image 782
DavidF Avatar asked Sep 09 '13 23:09

DavidF


3 Answers

You use the input group

<div class="input-group">
      <input type="text" class="form-control">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button">Go!</button>
      </span>
    </div>
like image 84
brandrich Avatar answered Nov 09 '22 20:11

brandrich


Try this:

  1. Remove class "form-inline" from the form
  2. Add class "input-group-btn" to the button

Resulting html:

<form id="frmOptions" method="post" class="span12">
    <div class="row-fluid">   
        <div class="form-group">
            <label class="control-label">File Name on Upload</label>
            <div class="input-group">
                <input id="uploadname" type="text" class="form-control">
                <a class="input-group-btn btn btn-default go inline">Upload to DocMan</a>
            </div>
        </div>
    </div>
</form>
like image 21
Vic Avatar answered Nov 09 '22 19:11

Vic


You can wrap it inside a div with the "navbar-form" class. That will put everything inside inline.

like image 5
Erik K. Avatar answered Nov 09 '22 20:11

Erik K.