2009-06-11 16 views
2

私は、HTML選択ボックスで国のリストとボタンを使用して、HTML選択ボックスで選択した項目の詳細を含む小さなウィンドウを開きます。ここで私のHTMLドロップダウンはIE6では機能しません

は(私はここにnoobishness、事前に謝罪、私はまだJavaScriptにかなり新しいです)私はこれをやっている方法は次のとおりです。

//in header 
<script type="text/javascript"> 
function popUp() 
{ 
    countryName = document.getElementById("countrylist").value; 
    document.write(countryName); 
    dest = "countries/" + countryName + ".html"; 
    window.open(dest, 0, "toolbar=0, scrollbars=0, statusbar=0, menubar=0,resizable=0,width=400,height=400,left=440,top=312"); 
} 
</script> 

<form id="countryform"> 
<select id="countrylist"> 
     <!--List of countries removed for brevity--> 
</select> 
<input type="button" name="countryBtn" value="Submit Query" onClick="popUp();"> 
</form> 

これはFirefoxではなく、IE6で正常に動作します。どんな助けもありがとう!

UPDATE:だから私は、以下の最初の二つのアプローチを試みたが、代わりのポップアップ機能は、いずれかのブラウザでは動作しませんでした、とのdocument.getElementByIdラインを交換しても何も変更していない、まだFirefoxで正常に動作し、しませんIEで。

答えて

0

は、ここで私はそれを固定方法は次のとおりです。

function popUp() 
{ 
    var c = document.getElementById("countrylist"); 
    var countryName = c.options[c.selectedIndex].text; 
    var dest = "countries/" + countryName + ".html"; 
    window.open(dest, 0, "toolbar=0, scrollbars=0, statusbar=0, menubar=0,resizable=0,width=400,height=400,left=440,top=312"); 
} 

これはIE6とFF3の両方で動作します。

助けてくれてありがとう!

6
document.getElementById("countrylist").value; 

する必要があります:

document.getElementById("countrylist")[document.getElementById("countrylist").selectedIndex].value; 
+0

よろしくお願いします。 。 –

0

あなたが持っている問題は、国の名前を取得しています。私があるためにあなたのポップアップ機能を変更します

function popUp() { 

    var e = document.getElementById("countrylist"); 

    var countryName = e.options[e.selectedIndex].value; 

    dest = "countries/" + countryName + ".html"; 
    window.open(dest, 0, "toolbar=0, scrollbars=0, statusbar=0, menubar=0,resizable=0,width=400,height=400,left=440,top=312"); 

} 
関連する問題