Shreyas Achar
Shreyas Achar

Reputation: 1435

Use Auto Complete instead of Dropdown in php

I have this below code snippet which will bind the station name to a dropdown list which is working fine.

I have gone through the tutorials they have fetched the data from query but here i am using REST API. So i needed a proper solution

<select id="Station" name="Station">
       <option selected="selected">Choose one</option>

  <?php
    foreach($someArray['stationList'] as $name) { ?>
      <option value="<?php echo $name['stationName'] ?>"><?php echo $name['stationName'] ?></option>
  <?php
  } ?>                                                                                                              </select>

Now i want to display the list of stations as autocomplete in a textbox rather than a dropdown list.

i.e If i type first three words of station than the related stations should be displayed.

Ex: If i type Del then the stations with the names related to Del should display

i.e Delhi

Delwara

Any Help Appreciated

Upvotes: 0

Views: 104

Answers (1)

David Delač
David Delač

Reputation: 367

You can't use pure PHP for that since It is not possible. You might have a go for it if you are willing to use database and get values from database and then use jQuery to auto-complete it.

Check this link out, It might be helpful.

https://www.upwork.com/hiring/development/creating-autocomplete-functionality-with-php-and-mysql/

Upvotes: 1

Related Questions