PHP中模糊查询并关联三个select框

1.在PHP中我们经常用到下拉框,并相互关联,如果下拉框的option非常多,那么我们就要用到模糊搜索功能,那么怎么做呢?

在此功能中,走了弯路,最好不要关联两个select的id值后select属性选中,并不可修改。再次选择的时候去除属性,这样在去除select属性的时候存在火狐和google js兼容的问题。很容易出现不对应或者属性不能去除的情况,且功能麻烦。另外在后台一定要判断两者的对应关系。(在后台比对两者的对应关系的时候,要去数据库查询,找到企业的id,去数据库查询担保公司的id比对。不要用前台取到担保公司的id值)。

2.样式:

相互关联,如果有担保公司则下拉框只显示一个担保公司,其他不显示,若没有,全部显示,让管理员选择。

3.我们知道select下拉框是不允许有搜索框的,也无法写一个input搜索框进去,这样我们只能借助插件来实现,把select框转换成ul li ,非常好用的插件:select2.

4.正常的在后台数据库获取数据,赋值;并引入select2插件即可。注意,和select2插件有关的css文件也要引入,有的css问价和js为封装好的,样式自己改。

normal; word-spacing: 0px; text-transform: none; color: rgb(0,0); text-align: center; font: medium Simsun; widows: 1; letter-spacing: normal; text-indent: 0px; -webkit-text-stroke-width: 0px">

normal; word-spacing: 0px; text-transform: none; color: rgb(0,0); text-align: center; font: medium Simsun; widows: 1; letter-spacing: normal; text-indent: 0px; -webkit-text-stroke-width: 0px">

5. 样式增加

.select2-results__option[aria-selected] { cursor: pointer; font-size: 14px; } .select2-container--default .select2-selection--single .select2-selection__rendered { color: #444; line-height: 28px; font-size:14px; } .select2-container--default .select2-results > .select2-results__options { max-height: 280px; overflow-y: auto; }

6. 下拉框之间的相互关联:

7.

8. js处理:获取隐藏的select值,重新组建select option(注意:select被隐藏后,他的值依然存在,并可利用)

normal; word-spacing: 0px; text-transform: none; color: rgb(0,0); text-align: center; font: medium Simsun; widows: 1; letter-spacing: normal; text-indent: 0px; -webkit-text-stroke-width: 0px">

normal; word-spacing: 0px; text-transform: none; color: rgb(0,0); text-align: center; font: medium Simsun; widows: 1; letter-spacing: normal; text-indent: 0px; -webkit-text-stroke-width: 0px">

以上所述是小编给大家介绍的PHP中模糊查询并关联三个select框,希望对大家有所帮助。程序员遇到问题都会上(编程之家jb51.cc)查找问题解答方法!如果觉得站点还不错,随手转发给程序员朋友一下!

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...