在层里放一个新的form,提交这个form就可以了

解决方案 »

  1.   

    我也试过在里面加个<form></form>的,可是加了后还是没有用,不能提交的,晕了
      

  2.   

    文件 index.htm  
    <HTML><HEAD><TITLE>index</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <SCRIPT src="css/layout.js" type=text/javascript></SCRIPT>
    <DIV><A 
    href="javascript:open_lw('login_win',350,190,'','')">登 陆</A></DIV>
    </BODY>
    </HTML>
    文件layout.js//新层的定义
    var LOGIN_WINDDOW = "<div style='height:28px; z-index:999; border-bottom:1px #c0d4db solid; background:#e7f0f7;FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#f7fcff,endColorStr=#e7f0f9)'></div><div style='line-height:30px;float:left; margin-top:-28px; padding-left:12px; font-family:simsun; font-size:12px; color:#0198cf'>用户登陆</div><div onclick='close_lw(login_win.id)' style='float:right; cursor:pointer;margin:-23px 3px 0px 0px ; padding: 1px 0px 0px 1px; height:8px; width:46px; color:#0198cf; font:12px;'><div style='float:right;width:16px;height:16px;background-image:url(images/leftall.gif) ;background-position: -14px -0px;'></div><b style='display:block;margin-top:4px;'>关闭</B></div><div id='login_error_div_back' style='width:100%;font-size:12px; height:12px;color:#000'><center id='login_error_div'></center></div><div style='margin:20px auto 10px 60px;width:210px; font-size:14px;color:#0198cf'>用户名:<input id='user_name' style='border:#0198cf 1px solid; width:120px; height:16px;' type='text' /></div><div style='margin:0px auto 10px 60px;;width:210px; font-size:14px; color:#0198cf'>密&nbsp;&nbsp;码:<input id='pass_word' style='border:#0198cf 1px solid; width:120px; height:16px;' type='password' /></div><div style='margin:0px 0px 0px 60px;width:210px; text-align:right;'><input id='login_button' onclick='layout_login()' style='border:#009ace 1px solid;background:#0198cf; width:100px; height:22px; margin-right:23px; color:#FFF; TabIndex='0' padding-top:2px;' type='submit' value='登 录' /></div>";
    var objX = 0;
    var objY = 0;
    function set_div_style(obj,id,top,left,width,height,position,border,cursor,background,filter)
        {
            var obj = obj;
    obj.style.filter=filter?"Alpha(Opacity="+filter+")":0;
            obj.id = id?id:null;
            obj.style.top = top?top:0;
            obj.style.left = left?left:0;
            obj.style.width = width?width:0;
            obj.style.height = height?height:0;
            obj.style.position = position?position:"static";
            obj.style.border = border?border:"1px #000 solid";
            obj.style.cursor = cursor?cursor:"default";
            obj.style.background = background?background:"";
            return obj
        }
    /////////////////////////////////////////////////////////////////////////////////
    //管理层的拖动
    function drag(obj)
        {
            if(objX!=0&&objY!=0)
            {
                if(event==null)
                {}
                else if(event.button == 1)
                    {
                    obj.style.left = event.clientX-objX;
                    obj.style.top = event.clientY-objY;
                    }
            }
        }function drag_mouse_down(obj)
        {
            var obj_left = obj.style.left;
            var obj_top = obj.style.top;
            var obj_left = obj_left.replace(/p|x/g,"");
            var obj_top = obj_top.replace(/p|x/g,"");
            var clientX = String(event.clientX).replace(/p|x/g,"");
            var clientY = String(event.clientY).replace(/p|x/g,"");
            objX = clientX - obj_left;
            objY = clientY - obj_top;
        }////////////////////////////////////////////////////////////////////////
    function open_lw(id,width,height)
        {
            if(!$(id))
                {
                var lw = document.createElement("div");
                var lw2 = document.createElement("div");
                var ifr = document.createElement("iframe");
                var lw_id = id;
                var lw2_id = id + "_lw2";
                var ifr_id = id + "_ifr";
                var lw_left = window.screen.width/2-width/2;
                var lw2_left = 0;
                var ifr_left = 0;
                var lw = set_div_style(lw,lw_id,200,lw_left,width,height,"absolute","0px solid #c0d4db","default","#fff");
                var lw2 = set_div_style(lw2,lw2_id,0,lw2_left,width,height,"absolute","1px solid #c0d4db","default","#fff");
                var ifr = set_div_style(ifr,ifr_id,0,ifr_left,width,height,"absolute","0px solid #c0d4db","default","#fff");
                
                document.body.appendChild(lw);
                lw.appendChild(ifr);
                lw.appendChild(lw2);
                
                lw2.innerHTML += LOGIN_WINDDOW;
                var drag_div = $('login_win_lw2').firstChild;
                document.body.onmousemove = function (){drag(lw)};
                document.body.onmouseup = function(){objX = 0;objY=0}
                drag_div.onmousedown = function (){drag_mouse_down(lw)};
                $("user_name").focus();
                }
        }function on_close(){
        {
            top.fresh_tasklist(0);
            if(window.top.$("set_tools_id")!=null)
            {
                var lw = window.top.$("set_tools_id");
                var lw2 = window.top.$("set_tools_id2");
                top.document.getElementById('set_tools').src = '';
                window.top.document.body.removeChild(lw);
                window.top.document.body.removeChild(lw2);
                 
            }
            if(window.top.$("set_row_id")!=null)
            {
                var lw = window.top.$("set_row_id");
                var lw2 = window.top.$("set_row_id2");
                top.document.getElementById('set_row').src = '';
                window.top.document.body.removeChild(lw);
                window.top.document.body.removeChild(lw2);
            }
        
        }
    }function close_lw(id)
        {
            if($(id))
            {
                var lw = $(id);
                document.body.removeChild(lw);
            }
        }function layout_login()
        {
            var usnm = $("user_name").value;
            var uspwd = $("pass_word").value;
            
            if(usnm=="")
                {
                    alert("请输入用户名");
                    $("user_name").focus();
                }
            else if(uspwd=="")
                {
                    alert("请输入密码");
                    $("pass_word").focus();
                }
            else
                {
                   location.href="1.asp"
                }
        }function $(id)
    {
    var obj = document.getElementById(id);
    if (obj != null)
    return obj;
    return null;
    }
      

  3.   

    1.要有form:
    var LOGIN_WINDDOW = "<form name=frm action='login.asp'><div ...>input id='login_button' onclick='layout_login()' style='border:#009ace 1px solid;background:#0198cf; width:100px; height:22px; margin-right:23px; color:#FFF; TabIndex='0' padding-top:2px;' type='submit' value='登 录' /></div></form>";2.如果“登录”按钮的type=submit。
    在没通过验证,不想提交时layout_login返回false,,并且:onclick="return layout_login();"3.你现在没提交的原因是,该提交时,你把它指向了1.asp
    function layout_login()
        {
    ...
            else
                {
                   location.href="1.asp"
                }
        }
      

  4.   

    谢谢啊,呵呵,我搞定了,我也加入过<form></form>的,可是之前是报错的,说是缺少对象,后面的location.href="1.asp"是因为搞不定表单时,我想通过直接用javascript来传递var usnm = $("user_name").value;   var uspwd = $("pass_word").value; 这两个值到数据库来验证的,可是没有搞定,呵呵,真是谢谢你啊