当我点击许可证的类别时,没有任何反应。
<script>
function goToPage( select1 ) {
var node = document.getElementById( select1 );
if( node &&
node.tagName == "SELECT" ) {
// Go to web page defined by the VALUE attribute of the OPTION element
window.location.href = node.options[node.selectedIndex].value;
} // endif
}
</script>
<center><label for="select1">Go to Marker</label></center>
<select id="select1" onChange="goToPage('select1')">
<?php
$conn=mysql_connect("localhost","root","");
mysql_select_db("dbposo",$conn);
$news=mysql_query("select id,license from tblviolator");
while($data=mysql_fetch_array($news))
{
$id=$data['id'];
$license=$data['license'];
print "
<option value='#X$id'>$license</option>
";
}
?>
</select>
答案 0 :(得分:0)
您只需按如下方式编写您的选择标记,而无需调用该函数。如果您只想重定向选择框的值
<select id="select1" onChange="window.location.href=this.value;">
更新2:
<script>
var current_url = window.location.href ;
function goToPage(val) {
window.location.href = current_url+val;
}
</script>
<select id="select1" onChange="goToPage(this.value);">