2012-02-27 19 views
0

URLとして値を持つ動的コンボボックスがあります。特定のアイテムが選択されると、URLに接続する必要があります。コンボボックス項目の値を持つhrefへの自動リンク値

これは私のコードです。

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を選択すると、Googleのページを取得する必要があります。上記のコードはiexplorer7で動作していますが、chromeとfirefoxでは動作しません。誰かが私が間違ったところで私を助けることができますか?代わりに "this.value" の

答えて

0

、 "this.options [this.selectedIndex] .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>'; 

EDIT ...それはそれは、文書の、上記ではありません。

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>'; 
+0

この1のみIE7で正常に動作し、作業FirefoxとChromeでhelp.Itsため – bharathi

+0

おかげで動作していない:LOCATION.HREF ...あなたは機能としてそれを呼んでいる、割り当てなければなりませんすべてのブラウザで正常です。 – bharathi

関連する問題