如何使用 php 在选择框中组织许多结果?
我有一个选择框,它是表单的一部分。它当前正在查询地址表并将地址显示到选择框中。我计划拥有最多 100 个地址。
我正在寻找一种解决方案,如果用户单击选择框,我可以显示所有状态。然后,如果用户将鼠标悬停在某个州上,它将显示该特定州的所有地址。然后,如果用户单击某个地址,它将在选择框中显示为所选选项。这就像选择框中的下拉菜单。
有谁知道我在哪里可以找到这样的解决方案?
I have a select box that is part of a form. It is currently querying the addresses table and displaying the addresses into the select box. I plan on having up to 100 addresses.
I'm looking for a solution where I can show all the states if the user clicks on the select box. Then if the user hovers over a state it will show all the addresses for that specific state. Then if the user clicks on an address, it will show that as the picked option in the select box. This is like a dropdown menu within a select box.
Does anyone know where I can find a solution as this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将所有地址预先加载到客户端,然后使用 JavaScript 或 CSS 来执行悬停操作,否则如果您选择在悬停操作上加载,您的用户将不得不等待 ajax 响应。但我不认为有一个预先编写的脚本可以为您执行这个确切的任务。但乍一看这似乎是 JQuery 的工作。
版本:
使用 javascript 的
onmouseover
而不是 CSS 的 :hover。 CSS 的:hover
仅适用于 IE 中的You will need to pre-load all addresses to the client side, then use JavaScript or CSS to perform hover actions, otherwise your user would have to wait for ajax response if you choose to load on hover action. But i don't think that there is a pre-written script that will perform this exact task for you. But right away it sounds like a job for JQuery.
Edition:
Use javascript's
onmouseover
instead of CSS's :hover. CSS's:hover
only works for<a>
in IE您没有指定服务器技术,所以我将采用 JS 解决方案。您要做的不是使用
任你选择。< /a> 显然,您必须自定义解决方案以满足您的需求。
编辑:下拉结构中的每个最终
都会有 JavaScript 在页面上设置隐藏的
,以便可以发布。
编辑 2:查看此 iPod 风格深入菜单:
You didn't specify the server technology, so I am just going to go with a JS solution. What you have to do is not use a
<select>
element and use something like a drop-down menu.Take your pick. You will have to customize the solution to suit your need obviously.
EDIT: Each final
<a>
in your drop down structure would have JavaScript to set a hidden<input>
on the page so it can be posted.EDIT 2: Check out this iPod style drill down menu: