主题: js方法提交后无法获取数据
作者: lty696, 发布日期: 2014-09-18 16:56:17, 浏览数: 1618

操作系统: xp
浏览器版本: ie8
KindEditor版本: KindEditor 4.1.10
BUG再现步骤:


<input name="Submit" type="submit" value="提交">这样提交后可以获取数据

但是以下方式无法获取到数据:

 

type="button" 使用onClick触发js提交后无法获取到数据!

<input name="Submit" type="button" value="这样提交获取不到数据" onClick="SubmitForm(0)">

 

测试代码如下:

<%
Action=Request.QueryString("action")
If Action="add" Then
	sContent=Request.Form("InfoContent")
	Response.Write(sContent)
End If
%>
<html>
<head>
<script language="javascript" type="text/javascript">
function SubmitForm(HaveParameters){
	if (HaveParameters="0"){
		//js处理过程忽略
	}
	document.form1.submit();
}
</script>
</head>
 
<body>
<form action="?action=add" method="post" name="form1" id="form1">
<textarea name="InfoContent" id="InfoContent" style="width:670px;height:200px;visibility:hidden;"></textarea><br>
<input name="Submit" type="submit" value="这样提交可以获取数据">&nbsp;&nbsp;<input name="Submit" type="button" value="这样提交获取不到数据" onClick="SubmitForm(0)"></form>
</body>
</html>


 

期望结果:

 

使用onClick触发document.form1.submit();也可以获取到数据同时输出

发表新帖 发表回复