繁体   English   中英

自动链接到带有组合框项目值的href

[英]Auto link to href with combo box items value

我有一个动态组合框,其URL为值。 选择特定项目后,我需要连接到URL。

这是我的代码。

  othercompaniesli.innerHTML=  '<select onchange="document.location.href(this.value);"> <option VALUE="http://google.com" >Google</option> <option VALUE="http://google.com" >TEST 1</option>  <option VALUE="http://google.com" >TEST</option> </select>';  

在这里,一旦选择了Google,就需要进入gogle页面。 上面的代码在iexplorer7中工作,而在chrome和firefox中工作。 在我犯错的地方,谁能帮助我。

尝试使用“ this.options [this.selectedIndex] .value”代替“ this.value”。

othercompaniesli.innerHTML=  '<select onchange="document.location.href(this.options[this.selectedIndex].value);"> <option VALUE="http://google.com" >Google</option> <option VALUE="http://google.com" >TEST 1</option>  <option VALUE="http://google.com" >TEST</option> </select>';  

编辑 ...不是上面的,它是document.location.href ...您将其称为函数,应该是一个赋值:

othercompaniesli.innerHTML=  '<select onchange="document.location.href = this.options[this.selectedIndex].value;"> <option VALUE="http://google.com" >Google</option> <option VALUE="http://google.com" >TEST 1</option>  <option VALUE="http://google.com" >TEST</option> </select>';  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM