簡體   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