Solved

Auto Submit of a Form !!! Help

Posted on 2003-11-05
16
211 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
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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now