2014-03-27 47 views
0

我想要做的是在window.showModalDialog中打開記錄取決於所選的下拉列表。我的問題始終是下拉菜單中的第一個值在新窗口中打開。在window.open中打開mysql的php記錄

如何在新窗口中打開記錄取決於我在動態下拉列表中選擇的內容?

<script>function modalWin() { 
if (window.showModalDialog) { 
window.showModalDialog("app_list2.php","name", 
"dialogWidth:1550px;dialogHeight:1550px;"); 
} else { 
window.open('app_list2.php','name', 
'height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes'); 
} 
} 
</script> 

<form action="app_list2.php" method="post" id="myform" onsubmit="modalWin(); return false;"> 
<select name="drop_1" id="drop_1" onchange="showUser(this.value)" style="overflow:scroll;width:100px;text-transform:uppercase;"> 
     <option value="ALL" selected='ALL'>ALL</option> 
     <?php getTierOne(); ?> 
</select> 

    <span id="wait_1" style="display: none;"> 
    <img alt="Please Wait" src="images/ajax-loader.gif" width="15px" height="15px"/> 
    </span> 
    <span id="result_1" style="display: none;"></span> 
</form> 
+0

當窗口打開時,您是否嘗試過使用散列作爲變量?像:'var hsh = $('#drop_1')。val()'?然後,您在使用JavaScript打開的頁面上測試'location.hash.replace('#','')'以跨瀏覽器兼容。 – PHPglue

回答

0

嘗試:

function modalWin(){ 
    var hsh = $('#drop1').val(); 
    if(showModalDialog){ 
    showModalDialog('app_list2.php#'+hsh,'name','dialogWidth:1550px;dialogHeight:1550px;'); 
    } 
    else{ 
    open('app_list2.php#'+hsh,'name','height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes'); 
    } 
} 

現在,您的網頁上打開:

if(location.hash.replace('#', '') === 'somevalue'){ 
    // do something accordingly 
} 

注:window是隱含的。你不寫window.document.getElementById(),是嗎?

+0

我有2個下拉列表 – user3462269