Forum Moderators: open

Message Too Old, No Replies

Auto submit form only once

currently it's looping

         

derek mcgilvray

1:12 pm on Nov 12, 2006 (gmt 0)

10+ Year Member



Hi folks,

I have an html form that I would like to autosubmit, so I've used javascript: document.form1.submit();

My problem is that when it returns a result to my page, it automatically submits the info in the form over and over again.

Is there a STOP command, or something else that I can put to stop this happening? I'd be grateful for any help received,

Derek

kaled

2:31 pm on Nov 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Presumably, when the form is submitted the same page is ultimately returned (as the form's action).

If you're using php, you should detect when the page is being delivered as a form action and ensure the resulting page does not autosubmit.

If you are using static html you should add a # value to the url when used as the form's action and not autosubmit when a # value is detected.

e.g.

<form action="page.html#done">...</form>

<script>
if (location.hash == '') form.submit();
</script>

Using a # value rather than an url parameter avoids possible duplicate content issues with search engines.

Kaled.

derek mcgilvray

3:44 pm on Nov 12, 2006 (gmt 0)

10+ Year Member



Thanks very much for your help Kaled, you have solved my problem for me - javascript is new for me at the moment you see. Thanks again,

Derek