Javascript Id在同一页上搜索
当我单击许可证的类别时,什么也没有发生Javascript Id在同一页上搜索,javascript,php,Javascript,Php,当我单击许可证的类别时,什么也没有发生 <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
<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>
函数goToPage(选择1){
var节点=document.getElementById(选择1);
if(节点&&
node.tagName==“选择”){
//转到由OPTION元素的VALUE属性定义的网页
window.location.href=node.options[node.selectedIndex].value;
}//endif
}
转到标记器
您只需按如下方式编写select标记,而无需调用函数。如果只想根据选择框的值重定向
<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);">
var current_url=window.location.href;
函数goToPage(val){
window.location.href=当前url+val;
}
您的URL最终应该看起来像example.com/mypage.php#X123-是这样吗?getelementbyid('select1')尝试引用是的,先生,我该怎么办(@CodingAnt什么也没发生:(你在firebug控制台上有错误吗?谢谢你,先生:)但是我仍然不能投票:)如果我有15个声望,我会投票给你:)