dongtang4954 2017-10-24 11:20
浏览 14

在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

  • 写回答

1条回答 默认 最新

  • dongwen3437 2017-10-24 11:24
    关注

    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/

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路