Auto Submit of a Form !!! Help

Hi Experts,
   I have an urgent issue in a HTML Document.

I need to click on the submit button to trigger an event and call a backend service. But I dont want the user to click on this button when the page is loaded[ It should be automatic when the page is loaded].. Is there a way to make this happen..
I dont want to use document.form1.submit() on load, because the event is based name="~event1" value="Refresh" of submit button.. Is there any way to simulate of clicking a Submit Button()..

<html>
<script>
<form name="form1" action="`wgateURL()`" method="post" >
<table>
  <tr>
    <td align=left>
      <input type="submit" name="~event1" value="Refresh">
    </td>
  </tr>
</table>
</form>
</body>
</html>

Any suggestion and help is appreciated.

Thanks,

Ganni
rganniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
<BODY onload='document.form1.elements["~event1"].click();' >
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BustaroomsCommented:
hey kEk, just curious is that somehow better / different than document.form1.submit()
0
knightEknightCommented:
but since you are submitting the form when the page loads, why use a button at all?  Why not just make the ~event1 element a hidden field and submit the form as usual?

   <input type="hidden" name="~event1" value="Refresh" />

and then do document.form1.submit() in the onload handler.


0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BustaroomsCommented:
o, well i guess that would make the onsubmit event fire
0
knightEknightCommented:
Bustarooms, no, IMO document.form1.submit() would be better -- but the question specifically ruled that out. :)
0
BustaroomsCommented:
yeah i didnt read the question.  maybe i should try that
0
knightEknightCommented:
oh, yes that is a good point about the onsubmit event, although in the example provided that is not a factor.
0
VincentPugliaCommented:
Hi,

  I agree with kek's solution:

bustaroom: by using the ...click(), you would also enable firing of other routines that may not be part of the form's submission per se.

<html>
<form name="form1" action="http://members.aol.com/grassblad" method="post" >
<table>
  <tr>
    <td align=left>
      <input type="submit" name="~event1" value="Refresh">
    </td>
  </tr>
</table>
</form>
<script>
document.form1.elements['~event1'].click()
</script>
</body>
</html>

Vinny
0
BustaroomsCommented:
hey guys, i wasnt suggesting anything.  i just saw kEk's post and didnt get why he suggested using .click() instead of .submit() because I didnt read the question i just saw the post
0
knightEknightCommented:
rganni, did any of this help you at all?
0
knightEknightCommented:
rganni, did any of this help you at all?
0
ZontarCommented:
I don't get this whole scenario, it seems really bassackawards... Why is there a need to post an HTML form at all, rather than just sending a HTTP POST request directly to the URL in question?
0
NeoHackerCommented:
use:
<BODY onload='document.form1.elements["~event1"].click();' > 
0
knightEknightCommented:
yes, that is what I suggested in my first post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.