2014-03-27 48 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