Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How to use autocomplete with form-inline and a submit button?

Rocks360 pro asked 6 years ago


How to use the autocomplete of mdbootstrap within a inline form search field and a button?

Marta Wierzbicka staff answered 6 years ago


Hi, Ok, great. Best, Marta

Rocks360 pro answered 6 years ago


Dear Marta, that's how I did it. I just override it with the use of media queries for the different device sizes. Best, Sven

Marta Wierzbicka staff answered 6 years ago


Hi, you have to add your custom CSS and to replace our one. For now it is:
.form-inline .md-form .form-control.mdb-autocomplete { width15rem; }
So, replace this value with your one.
Best,
Marta

Rocks360 pro answered 6 years ago


Dear Marta, thank you for your answer :)! Yes it is almost like I wanted to have it. Do you have an idea of how I can make the searchbar width longer? I wrapped it up in a row like the following:
<div class="row">
<div class="col-md-6 offset-md-3">
<div class="d-flex justify-content-center">div>
/** search form **/
</div>
</div>
</div>

Marta Wierzbicka staff answered 6 years ago


Hi, You mean something like that?
<form class="form-inline">

<div class="md-form mr-3">
<input type="search" id="form-autocomplete" class="form-control mdb-autocomplete">
<button class="mdb-autocomplete-clear">
<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
<path d="M0 0h24v24H0z" fill="none" />
</svg>
</button>
<label for="form-autocomplete" class="active">What is your favorite US state?</label>
</div>

<button type="submit" class="btn btn-primary btn-md mb-2"><i class="fa fa-search"></i></button>

</form>
var states = [
"Alabama",
"Alaska",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware",
"Florida",
"Georgia",
"Hawaii",
"Idaho",
"Illnois",
"Indiana",
"Iowa",
"Kansas",
"Kentucky",
"Louisiana",
"Maine",
"Maryland",
"Massachusetts",
"Michigan",
"Minnesota",
"Mississippi",
"Missouri",
"Montana",
"Nebraska",
"Nevada",
"New Hampshire",
"New Jersey",
"New Mexico",
"New York",
"North Carolina",
"North Dakota",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"South Carolina",
"South Dakota",
"Tennessee",
"Texas",
"Utah",
"Vermont",
"Virginia",
"Washington",
"West Virginia",
"Wisconsin",
"Wyoming"
];

$('#form-autocomplete').mdb_autocomplete({
data: states
});
Best, Marta

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.5.1
  • Device: MacBook,
  • Browser: Safari, Internet Explorer, Crome
  • OS: MacOS, Microsoft
  • Provided sample code: No
  • Provided link: No