• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Submit form on load event of body/window

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In my project the requirement is to submit a form on the load event of the body. But if I call the submit function on the load event of body, my form is submitting again and again and again and go into an infinite loop. Kindly tell me the way in which i can submit the form only once on the load event of the body.


Thanks & Regards,
Jatinder Arora.
[ July 13, 2005: Message edited by: dimpsonu arora ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiest way would be to submit the form to a different page, not the same one. If it has to be the same page, you could embed a JavaScript variable that is normally 0, but set to 1 when the form has been processed. You then check its value in the onload handler, and only submit if the value is 0.

(By the way: What good is having a web page when on loading its form is automatically submitted, so that the user never gets to see the page?)
[ July 13, 2005: Message edited by: Ulf Dittmer ]
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think it kinda imposible to do that !
can i know what is the perpose of that ? and the solution given by Ulf i think it will not solve the problem because when you assign a value to the variable and submit the form the initial value will be the value that the page will check on it when the form is loading !!! try it again, I try it and does not work.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is certainly possible.
on the server side where you write the JSP/SERVLET code you can decide based on some condition whether to include onload function in the page or not. in the end the server generates the html page right?
so why cant we decide what it should generate?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best solution would be for the server side code to write the onload statement to the page.

The other option is to use a session cookie...

Eric
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't want the current page to change, but don't want to open up a new window either, you can always submit to a hidden iframe or use Ajax. The user won't even know that the form has been submitted unless you decide to let him know.

-Yuriy
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic