Click to See Complete Forum and Search --> : using the settimeout function..please help


bluestar
11-01-2003, 01:41 PM
hello
how can i use the settimeout function to automatically submite a form after a certain time???
please help

Charles
11-01-2003, 02:44 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example</title>

<style type="text/css">
<!--
label {display:block; margin:1em 0em}
input {display:block}
-->
</style>

<script type="text/javascript">
<!--
function verify (form) {for (var j=0; j<form.elements.length; j++) {if (!/\S/.test(form.elements[j].value)) {alert(['Field', form.elements[j].previousSibling.data, 'is required.'].join(' ')); form.elements[j].focus(); return false}}}

onload = function () {setTimeout('if (document.forms[0].onsubmit() != false) document.forms[0].submit()', 500)}
// -->
</script>

<form action="http://www.w3.org/" onsubmit="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example</title>

<style type="text/css">
<!--
label {display:block; margin:1em 0em}
input {display:block}
-->
</style>

<script type="text/javascript">
<!--
function verify (form) {for (var j=0; j<form.elements.length; j++) {if (!/\S/.test(form.elements[j].value)) {alert(['Field', form.elements[j].previousSibling.data, 'is required.'].join(' ')); form.elements[j].focus(); return false}}}

onload = function () {setTimeout('if (document.forms[0].onsubmit()) document.forms[0].submit()', 500)}
// -->
</script>

<form action="http://www.w3.org/" onsubmit="return verify(this)">
<div>
<label>Name<input id="name" type="text"></label>
<label>Rank<input id="rank" type="text"></label>
<label>Serial Number<input id="serialNumber" type="text"></label>
<button type="submit">Submit</button>
</div>
</form>
">
<div>
<label>Name<input id="name" type="text"></label>
<label>Rank<input id="rank" type="text"></label>
<label>Serial Number<input id="serialNumber" type="text"></label>
<button type="submit">Submit</button>
</div>
</form>