[英]Select box Onchange: autosubmit() option with php
So it's like I have a selectbox, with while loop as option as I want to bring out the options from database, is it possible to click on the option and link? 就像我有一个选择框一样,当我想从数据库中提取选项时,将while循环作为选项,是否可以单击该选项并链接?
The while loop is like this while循环是这样的
while ($row = mysqli_fetch_assoc($result0))
{
$option .= '<option value="'.$row['id'].'">'.$row['Font_Family'].'</option>';
}
This is the select box 这是选择框
<select id='font' style="width:100px;" onchange="autosubmit();">
<option value ="0">Select</option>
But on clicking the option I want to link it to 但是在单击该选项时,我想将其链接到
font.php?id={id that is being pointed to}
How can I do this? 我怎样才能做到这一点?
Use Javascript to call the onchange. 使用Java脚本调用onchange。
Between the header tags, put: 在标题标签之间,输入:
<script type="text/javascript">
function autosubmit() {
window.location="font.php?id="+document.getElementById("font").value;
}
</script>
View the working jsbin: http://jsbin.com/uwuyoz/1/ 查看有效的jsbin: http ://jsbin.com/uwuyoz/1/
Please note, you'll have to uncomment the window.location. 请注意,您必须取消注释window.location。 I simply have it 'alerting' now.
我现在只是在“改变”。 But all the code is there.
但是所有代码都在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.