对于那些对“不可能”感兴趣的人:我已经解决了我自己的问题,没有使用 JS 或表单/提交,所以你可以在任何地方使用它,包括服务器端。答案是我每天都在使用的东西(在菜单中),直到今天我仍然无法建立联系。该解决方案包括一些花哨的 CSS,如果您想要普通下拉框的外观,您可以对其进行简化。这是php代码,后面是css:
echo "<td><ul id='dropselect' class='droptable'>
<li class='droptable'><a href='".$_SERVER['PHP_SELF']."?sel_type=All types' title='Click one of the types in the list, to limit the db selection'><span>All types</span></a>
<ul>";
while($fetch_type = mysql_fetch_array($droptype)) {
echo "<li><a href='".$_SERVER['PHP_SELF']."?sel_type=".$fetch_type['type_desc']."'><span>".$fetch_type['type_desc']."</span></a>";
};
echo "</li></ul></ul></td>";
这是CSS;您可以将其直接复制到样式表中:
ul#dropselect,ul#dropselect ul{
margin:0;list-style:none;padding:0;background-color:#dedede;border-width:1px;border-style:solid;border-color:#5f5f5f;
-moz-box-shadow:3.5px 3.5px 5px #000000;
-webkit-box-shadow:3.5px 3.5px 5px #000000;
box-shadow:3.5px 3.5px 5px #000000;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;}
ul#dropselect ul{
display:none;position:absolute;left:0;top:100%;
-moz-box-shadow:3.5px 3.5px 5px #000000;
-webkit-box-shadow:3.5px 3.5px 5px #000000;
box-shadow:3.5px 3.5px 5px #000000;
background-color:#79beff;border-radius:6px;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-color:#d4d4d4;padding:0 10px 10px;}
ul#dropselect li:hover>*{
display:block;}
ul#dropselect li{
position:relative;display:block;white-space:nowrap;font-size:0;float:left;}
ul#dropselect li:hover{
z-index:1;}
ul#dropselect ul ul{
position:absolute;left:100%;top:0;}
ul#dropselect{
font-size:0;z-index:999;position:relative;display:inline-block;zoom:1;padding:0;
*display:inline;}
* html ul#dropselect li a{
display:inline-block;}
ul#dropselect>li{
margin:0;}
ul#dropselect a:active, ul#dropselect a:focus{
outline-style:none;}
ul#dropselect a{
display:block;vertical-align:middle;text-align:left;text-decoration:none;font:bold 15px Trebuchet MS;color:#55aaff;text-shadow:#FFF 0 0 1px;cursor:pointer;padding:10px;background-color:#c1c1c1;background-image:url("mainbk.png");background-repeat:repeat;background-position:0 0;border-width:0 0 0 1px;border-style:solid;border-color:#C0C0C0;}
ul#dropselect ul li{
float:none;margin:10px 0 0;}
ul#dropselect ul a{
text-align:left;padding:2px;background-color:#79beff;background-image:none;border-width:0;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px;font:15px Tahoma;color:#ffffff;text-decoration:none;}
ul#dropselect li:hover>a,ul#dropselect li a.pressed{
background-color:#79beff;border-color:#C0C0C0;border-style:solid;color:#ffffff;text-shadow:#FFF 0 0 1px;background-image:url("mainbk.png");background-position:0 100px;text-decoration:none;}
ul#dropselect span{
display:block;overflow:visible;background-position:right center;background-repeat:no-repeat;padding-right:2px;}
ul#dropselect ul li:hover>a,ul#dropselect ul li a.pressed{
background-color:#FFFFFF;background-image:none;color:#0978b3;text-decoration:none;}