?
Solved

Auto Submit of a Form !!! Help

Posted on 2003-11-05
16
Medium Priority
?
221 Views
Last Modified: 2011-09-20
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
0
Comment
Question by:rganni
14 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 1000 total points
ID: 9688562
<BODY onload='document.form1.elements["~event1"].click();' >
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9688586
hey kEk, just curious is that somehow better / different than document.form1.submit()
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9688591
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:Bustarooms
ID: 9688595
o, well i guess that would make the onsubmit event fire
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9688601
Bustarooms, no, IMO document.form1.submit() would be better -- but the question specifically ruled that out. :)
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9688611
yeah i didnt read the question.  maybe i should try that
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9688621
oh, yes that is a good point about the onsubmit event, although in the example provided that is not a factor.
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9688834
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
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9688855
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
 
LVL 33

Expert Comment

by:knightEknight
ID: 9702749
rganni, did any of this help you at all?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9763522
rganni, did any of this help you at all?
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9795998
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
 

Expert Comment

by:NeoHacker
ID: 10018715
use:
<BODY onload='document.form1.elements["~event1"].click();' > 
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10019315
yes, that is what I suggested in my first post.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question