模态对话框传值及接收值

function setCn(row){
    var sURL = "*.jsp? type=cc&random="+new Date().getTime();"
    var vArguments = new Object();//对话框经过window.dialogArguments来取得传递进来的参数。
    vArguments.win=window;//把当前窗口的引用当参数传进去
    vArgument s.str=$(row).val();//要传进去的其余参数
    var sFeatures = "dialogHeight:350px;dialogWidth:550px;center:yes;resizable:yes;status:no;location:no;menubar:no;titlebar:no;";
    var vReturn=window.showModalDialog(sURL,vArguments,sFeatures);
    if(undefined != vReturn){
        $(row).val(vReturn);
    }
}

<style type="text/css">   
    #main { height: auto; width: auto;float: left; }
</style>
<script type="text/javascript">
var arg=window.dialogArguments;    
var pa = ${param.type};
$(function(){
    $("#kk").val( arg.str);
    if(pa == 'cc'){
        $("#title").html("");
    }else{
        $("#title").html("");
    }
})

function submitForm(){
    var v = $("#abc").val();
    
    var result= v.match(/^\w+(\.)\w+$/); //将匹配的对象做为数组返回
    if(result ==null){
 $("#abc").focus();                                                                                                                                                   alert("格式不对");
        return ;
    }
    
    if(pa == 'cc'){
        var r = (/[\u4e00-\u9fa5]+/ig) .test($.trim(v));//是否包含
        if(r){
            alert("error data!");
            $("#abc").focus();
            return ;
        }
    }
    window. returnValue=cnValue;     window.close(); } </script> </head> <body> <form id="form" action="" method="post"> <div id="main">     <table id="Table" width="100%" border="0" align="center" >         <tr >             <th id="title" align="center"></th>         </tr>             <tr >             <td width="100%" height="90%">             <s:textarea cols="65" rows="18" id="abc"></s:textarea></td>         </tr>     </table>     <span><a href="javascript:void(0);"  onclick="submitForm();">肯定</a></span> </div> </form>    
相关文章
相关标签/搜索