1

I am creating a search bar using Bootstrap#input-groups-buttons

  <form class="navbar-form navbar-left" action=".">
      <div class="input-group">
        <input type="text" class="form-control" name="q" placeholder="Search ...">
        <span class="input-group-btn">
          <button class="btn btn-default" type="button">Go!</button>
        </span>
      </div><!-- /input-group -->
  </form>

When I press Enter, the form could be submitted successfully,

http://127.0.0.1:8000/?q=test

However, when I click the button "Go", nothing happened.

How could I submit the form data when button is click?

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138

3 Answers3

2

Just change the button type as submit.

<button class="btn btn-default" type="submit">Go!</button>.

Check for details: https://www.w3schools.com/tags/att_button_type.asp :)

Eugine Joseph
  • 1,552
  • 3
  • 18
  • 40
1

Suppose your form has the id of myForm

<button type="submit" class="btn btn-default" form="myForm" value="Submit">Go!</button>
Ilan P
  • 1,602
  • 1
  • 8
  • 13
0

I am betting you just need to bind the button to execute your event handler on click events - bootstrap handles the presentation, but you would also want something like jQuery to specify how to handle UI events. You might want to read: Bootstrap onClick button event

moilejter
  • 958
  • 8
  • 9