Forum Moderators: open

Message Too Old, No Replies

How can i auto submit a POST form

         

laura2k

7:13 pm on Jun 17, 2004 (gmt 0)



Hi there,

I have a form that has a textfield called QTY,

Can someone please tell me how i can auto submit the form when the value of this text field is changed.

Thanx in advanced.

DrDoc

7:30 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can add this to the field:

onchange="this.form.submit()"

Birdman

8:22 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



deleted due to bad advice. See below.

[edited by: Birdman at 8:45 pm (utc) on June 17, 2004]

DrDoc

8:26 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onchange
doesn't get triggered until the input field is blurred anyway...

DrDoc

8:32 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this would work:

<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
var foo;
function submitTheForm(which) {
which.form.submit();
}
</script>
</head>
<body>
<form>
Qty:
<input name="qty" type="text" onchange="submitTheForm(this)" onkeyup="foo = setTimeout('submitTheForm(this)',1000)" onkeydown="if(foo){clearTimeout(foo)}">
</form>

</body>
</html>

The form will submit immediately on blur (change)... It will also submit within 1 second of the last key press. So, if you type "10" and don't pause more than 999 milliseconds between the key presses it will not submit until you're done typing.

ahmad_fathy

1:46 pm on Jul 12, 2004 (gmt 0)

10+ Year Member



it doesnt work