[英]Form submit button does not work in Firefox but works in Chrome or IE
I have a form with some input fields and a submit button.我有一个包含一些输入字段和提交按钮的表单。 The form should submit to a servlet.表单应提交给 servlet。
When I hit submit/return, everything is fine in Chrome or IE, but it does nothing on Firefox.当我点击提交/返回时,在 Chrome 或 IE 中一切正常,但在 Firefox 上没有任何作用。 Any idea about the issue?对这个问题有什么想法吗?
HTML: HTML:
<body>
<div align="center">
<form>
<table cellpadding ='2' border ='0'>
<tr>
<td>
<label for="Database">Database</label>
</td>
<td>
<input id="database" type="text" onchange="setdirtybit()" name="Database" style="width:200px"></input>
</td>
</tr>
<tr>
<td>
<label for="Script">Script</label>
</td>
<td>
<input id="script" type="text" onchange="setdirtybit()" name="Script" style="width:200px"></input>
</td>
</tr>
</table>
<br />
<input type ='submit' value='Submit' onclick='Close()'></input>
</form>
</div>
</body>
JavaScript: JavaScript:
function Close()
{
window.returnValue = "";
if(window.dirtyFlag)
{
document.forms[0].method="post";
document.forms[0].action="/nbreports/updates/";
document.forms[0].submit();
window.returnValue = getValue('database') + '/' +
getValue('script') ;
}
window.close();
}
function getValue(varName)
{
if(document.getElementById(varName) == null)
return "";
if(document.getElementById(varName).value == null)
return "";
else
return document.getElementById(varName).value;
}
function setdirtybit()
{
window.dirtyFlag = 1;
}
$('#mytextfield').change(function(e) {
$('input[type=submit]').focus();
});
put an Id on your submit button, them do like this:在你的提交按钮上放一个 ID,他们这样做:
$(document).ready(function(){
$('#submitButtonId').click(function(){
var url = 'myServletUrlHere';
var data = $('form').serialize();
$.ajax({
type: 'POST',
url: url,
data: data,
success: alert("It worked!")
});
});
});
I am not sure but I do know that the following form does not work in Firefox but it works in all the other browsers:我不确定,但我知道以下表单在 Firefox 中不起作用,但在所有其他浏览器中都有效:
<form method="POST">
<textarea rows="4" cols="60" name="body"></textarea><br>
<input type="submit" value="Submit">
</form>
It's like the submit button doesn't even process the mouse clicks.就像提交按钮甚至不处理鼠标点击一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.