1

所以就像我有一个选择框,带有while循环作为选项,因为我想从数据库中取出选项,是否可以单击选项和链接?

while循环是这样的

while ($row = mysqli_fetch_assoc($result0))
{
$option .= '<option value="'.$row['id'].'">'.$row['Font_Family'].'</option>';
}

这是选择框

<select id='font' style="width:100px;" onchange="autosubmit();">
            <option value ="0">Select</option>

但是在单击我想将其链接到的选项时

 font.php?id={id that is being pointed to}

我怎样才能做到这一点?

4

1 回答 1

0

使用 Javascript 调用 onchange。

在标题标签之间,放置:

  <script type="text/javascript">
    function autosubmit() {
      window.location="font.php?id="+document.getElementById("font").value;
    }
  </script>

查看工作的 jsbin:http: //jsbin.com/uwuyoz/1/

请注意,您必须取消对 window.location 的注释。我现在只是让它'警报'。但是所有的代码都在那里。

于 2013-05-30T01:55:41.947 回答