简体   繁体   中英

How to be able to type in desired value when value has been changed

I have a massive select with all the books of the bible listed, then attached an AJAX request being sent out for a PHP script. I want users to be able to type in the first couple of letters of the desired book, and the browser is currently looking for a value that has been changed to a number. Such as:

<option value="1" onchange="change_book();">Genesis</option>

How do I either A) Have JavaScript look for another, unique value or B) have the browser render something else I'm not aware of?

First off, you can't bind an onchange event to an <option> tag because those don't change. <select> does.

Second, you mention typing. It sounds like you want something like autocomplete

看一下Select2选择框库,特别是“ 加载远程数据”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM