16

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.

4 Answers 4

19

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>
Sign up to request clarification or add additional context in comments.

2 Comments

hmm doesn't work for me.. the button goes to a new line
Note: This works with Bootstrap 3. If it does not work for you, check if you are using an older Bootstrap version.
14

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>

1 Comment

This makes the button float all the way to the right. How can I force it to stay next to the text input?
5

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

Comments

0

One option is to override the display:block; style of the class form-control. I have posted sample code in following reply:

bootstrap: align input with button

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.