Forum Moderators: open

Message Too Old, No Replies

HELP! Auto submitting form only once.

But , it keeps looping and submitting the same information again N again!

         

jokomamamita

5:20 am on Sep 26, 2006 (gmt 0)

10+ Year Member



hello friends!..

I have a code which would auto-submit a POST form so that I could get to know my site visitors where as it would post some details about them ....But, the problem is, it keep submitting the same information over and over again!....I meant, it keeps looping!....I dunno how to make the form auto-submit only once!....And oh yeah, the form is targetted to a IFRAME so that the page won't change to another page!..

thanx in advance! =)

here's an overview look of the code :


<script type="text/javascript">
window.onload = function () {document.tracker_form.submit();}
</script>
<form name="tracker_form" action="tracker.php" target="nothing" method="post">
.............
.............
.............
.............
</form>
<iframe name="nothing" width=1 height=1 scrolling=no></iframe>

daveVk

5:31 am on Sep 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably cleaner way but changing

window.onload = function (){document.tracker_form.submit();}

TO

window.onload = function (){window.onload=NULL;document.tracker_form.submit();}

should do the trick;

jokomamamita

6:09 am on Sep 26, 2006 (gmt 0)

10+ Year Member



thanx for trying to help me!... =)

I tried your method but the form never submitted any information at all.. =(

here's the code that I used :


<script type="text/javascript">
window.onload = function (){window.onload=NULL;document.tracker_form.submit();}
</script>
<form name="tracker_form" action="tracker.php" target="nothing" method="post">
.............
.............
.............
.............
</form>
<iframe name="nothing" width=1 height=1 scrolling=no></iframe>

thanx again!

daveVk

6:25 am on Sep 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OPS try

window.onload = function (){window.onload={};document.tracker_form.submit();}

orion_rus

6:51 am on Sep 26, 2006 (gmt 0)

10+ Year Member



You can make it simply then naver:
declare global variable
var submitonce=true;
if a checking function there you return false or true then form is correct
if you have:
return result;
make:
realresult=result&&submitonce
if (result) submitonce=false;
return realresult;
and it would be crossing with variable always false - form not validate always after first sending

jokomamamita

8:10 am on Sep 26, 2006 (gmt 0)

10+ Year Member



@ daveVK - your method doesn't seemed to work! It keep submitting the same information over and over again!....or in other words, the auto-submit form keeps looping! anyway, thanx! =)

@ orion_rus - thanx for the help, but, im a newbie in this javascript thingy!...could u edit the code that I had given in my first post and help me out?...thanx in advance! =)

jokomamamita

9:16 am on Sep 29, 2006 (gmt 0)

10+ Year Member



Anyone else? =(

daveVk

10:55 am on Sep 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make sure tracker.php has no tracking code in it, or other javascript that may be a problem. Also try firing on body onload instead on window onload as below.

<body onload={alert(1);document.tracker_form.submit();alert(2);} >
...
<form name="tracker_form" action="tracker.php" target="nothing" method="post">
.............
.............
.............
.............
</form>
<iframe name="nothing" width=1 height=1 scrolling=no></iframe>
...
</body>

The alerts, bold text, are there for debugging only (to see where looping), take out if all goes well.