首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

为什么小弟我用javascript提交不了表单到CGI

2012-02-13 
为什么我用javascript提交不了表单到CGI?望高手帮忙使用普通的HTML提交邮箱登陆表单可以:FORMnamelogona

为什么我用javascript提交不了表单到CGI?
望高手帮忙
使用普通的HTML提交邮箱登陆表单可以:
<FORM   name=logon   action= "http://vip.mscbsc.com:8383/login.cgi "   method=post>
邮箱名:   <INPUT   type=hidden   value=login   name=page>
<INPUT   class=input   name=userid>  
密码: <INPUT   class=input   type=password   size=13   name=passwd>  
<INPUT   type=image   height=24   hspace=6   width=68     src= "img/newsubmit.gif "   border=0   name=image>  
</FORM>
用javascript自动加邮箱后缀却不行,但下面这个提交163邮箱是可以的:
<body   topmargin= "0 ">  
<div   align= "center ">   <center>   <div   align= "CENTER ">   </div> </center> </div> <div   align= "center ">  
<center>   <div   align= "center ">   <center>   <table   width= "760 "   border= "0 ">   <form   name= "loginmail "   onsubmit= "return   WriteNewLogin(this); "   method= "post ">  
<tr>   <td>   <p> <strong> <font   color= "#CC6600 "> 邮箱帐号: </font> </strong>   <input   style= "FONT-SIZE:   12px "   tabindex= "1 "   size= "14 "   name= "user ">  
<select   tabindex= "2 "   size= "1 "   name= "site ">
    <option   value= "none "   selected> @选择你的邮箱 </option>
    <option   value= "163.com "> @163.com </option>
    <option   value= "vip.mscbsc.com "> @vip.mscbsc.com </option>
</select>   密码:   <input   style= "FONT-SIZE:   12px "   tabindex= "3 "   type= "password "   size= "13 "   name= "pass ">  
<input   style= "FONT-SIZE:   12px "   tabindex= "4 "   type= "submit "   value= "登录 "   name= "Submit2 ">  
</p> </td> </tr>  
</form> </table>
</body>  
<script   language= "javascript ">  
var   loginSite= " "  
var   loginUser= " "  
var   loginPass= " "  
var   HTMLurl   = " <html> <head> <meta   http-equiv=Content-Type   content=text/html;   charset=gb2312> </head> <body> "  
var   OtherInfo= " "  
function   WriteNewLogin(the){  
if   (the.site.value== "none "){  
alert( "请先选择一个要登录的邮局! ")  
return   false  
}  
switch(the.site.value){  
case   "163.com ":  
loginSite= "http://reg.163.com/in.jsp?url=http://fm163.163.com/coremail/fcg/ntesdoor2?language%3D-1%26style%3D-1 "  
loginUser= "username "  
loginPass= "password "  
break;  
case   "vip.mscbsc.com ":  
the.user.value+= "@vip.mscbsc.com "  
loginSite= "http://vip.mscbsc.com:8383/login.cgi "  
loginUser= "userid "  
loginPass= "passwd "  
OtherInfo= " <INPUT   type=hidden   value=login   name=page> "  


break;  
default:  
alert( "无效的邮件服务器名称! ")  
return   false  
}  
HTMLurl   = " <form   name= 'logon '   method= 'post 'action= "+loginSite+ "> "  
HTMLurl   += " <input   type=text   name= "+loginUser+ "   value= "+the.user.value+ "> "  
HTMLurl   += " <input   type=password   name= "+loginPass+ "   value= "+the.pass.value+ "> "  
HTMLurl   +=OtherInfo  
HTMLurl   += " <input   type=submit   name=Submit   value=提交> "  
HTMLurl   += " </form> "  
document.getElementById( "TmpmailForm ").innerHTML=HTMLurl  
document.logon.submit()  
the.user.value= " "  
the.pass.value= " "  
return   false  
}  
haokan=document.haokanlogin  
function   ClickForm(){  
haokan.submit()  
haokan.Username.value= " "  
haokan.passWord.value= " "  
}  
function   LoginHaokan(){  
if   (window.event.keyCode==13){  
ClickForm()  
}   }  
</script>

[解决办法]
<html>
<head>
<META http-equiv= "Content-Type " content= "text/html; charset=gbk ">
<META HTTP-EQUIV= "pragma " CONTENT= "no-cache ">
<title> </title>
<STYLE>
</STYLE>
</head>

<body topmargin= "0 " id=TmpmailForm>
<div align= "center "> <center> <div align= "CENTER "> </div> </center> </div> <div align= "center ">
<center> <div align= "center "> <center> <table width= "760 " border= "0 ">
<form name= "loginmail " onsubmit= "return WriteNewLogin(this); " method= "post ">
<tr> <td> <p> <strong> <font color= "#CC6600 "> 邮箱帐号: </font> </strong> <input style= "FONT-SIZE: 12px " tabindex= "1 " size= "14 " name= "user ">
<select tabindex= "2 " size= "1 " name= "site ">
<option value= "none " selected> @选择你的邮箱 </option>
<option value= "163.com "> @163.com </option>
<option value= "vip.mscbsc.com "> @vip.mscbsc.com </option>
</select> 密码: <input style= "FONT-SIZE: 12px " tabindex= "3 " type= "password " size= "13 " name= "pass ">
<input style= "FONT-SIZE: 12px " tabindex= "4 " type= "submit " value= "登录 " name= "Submit2 ">
</p> </td> </tr>
</form> </table>
</body>
<script language= "javascript ">
var loginSite= " "
var loginUser= " "
var loginPass= " "
var HTMLurl = " <html> <head> <meta http-equiv=Content-Type content=text/html; charset=gb2312> </head> <body> "
var OtherInfo= " "
function WriteNewLogin(the)
{
if (the.site.value== "none "){
alert( "请先选择一个要登录的邮局! ")
return false


}
switch(the.site.value){
case "163.com ":
loginSite= "http://reg.163.com/in.jsp?url=http://fm163.163.com/coremail/fcg/ntesdoor2?language%3D-1%26style%3D-1 "
loginUser= "username "
loginPass= "password "
break;
case "vip.mscbsc.com ":
the.user.value+= "@vip.mscbsc.com "
loginSite= "http://vip.mscbsc.com:8383/login.cgi "
loginUser= "userid "
loginPass= "passwd "
OtherInfo= " <INPUT type=hidden value=login name=page> "
break;
default:
alert( "无效的邮件服务器名称! ")
return false
}
HTMLurl = " <form name= 'logon ' method= 'post 'action= "+loginSite+ "> "
HTMLurl += " <input type=text name= "+loginUser+ " value= "+the.user.value+ "> "
HTMLurl += " <input type=password name= "+loginPass+ " value= "+the.pass.value+ "> "
HTMLurl +=OtherInfo
HTMLurl += " <input type=submit name=Submit value=提交> "
HTMLurl += " </form> "
document.getElementById( "TmpmailForm ").innerHTML=HTMLurl
document.logon.submit()
//the.user.value= " "
//the.pass.value= " "
return false
}
haokan=document.haokanlogin
function ClickForm()
{
haokan.submit()
haokan.Username.value= " "
haokan.passWord.value= " "
}
function LoginHaokan(){
if (window.event.keyCode==13){
ClickForm()
} }
</script>
</html>

热点排行