Solved

Auto Submit of a Form !!! Help

Posted on 2003-11-05
16
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 250 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
Industry Leaders: 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!

 
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

Technology Partners: 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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 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