automatically submit form js code example
Example 1: js stop form submit
<button type="submit" onclick="submitButtonClick(event)">Submit</button>
<script>
function submitButtonClick(event) {
event.preventDefault();
}
</script>
Example 2: submit form automatically javascript
<form name="myForm" id="myForm" target="_myFrame" action="test.php" method="POST">
<p>
<input name="test" value="test" />
</p>
<p>
<input type="submit" value="Submit" />
</p>
</form>
<script type="text/javascript">
window.onload=function(){
var auto = setTimeout(function(){ autoRefresh(); }, 100);
function submitform(){
alert('test');
document.forms["myForm"].submit();
}
function autoRefresh(){
clearTimeout(auto);
auto = setTimeout(function(){ submitform(); autoRefresh(); }, 10000);
}
}
</script>