DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> js彈出模式對話框,並接收回傳值的方法
js彈出模式對話框,並接收回傳值的方法
編輯:關於JavaScript     

彈出對話框的頁面A:

復制代碼 代碼如下:
<script type="text/javascript">
    function openDialog(){
        paramers="dialogWidth:500px; dialogHeight:300px; status:no";
        workerId = window.showModalDialog("userList.aspx","",paramers);
        if(workerId!=undefined && workerId!=""){
            document.getElementById("leader").value = workerId;
          }
        }
</script>

模式對話框js:

復制代碼 代碼如下:
<input type="button" value="選擇" onclick="javascript:selectPositionAndClose();"/>

    </form>
<script type="text/javascript">
    function selectPositionAndClose(){
        var obj = document.getElementById("userList");

        var user = "";
        for(var i=0;i<obj.options.length;i++){

            if(obj.options[i].selected==true){
                user = obj.options[i].value;
            }
        }

        window.returnValue = user;
        window.close();
    }
</script>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved