Solved

Auto Submit of a Form !!! Help

Posted on 2003-11-05
16
213 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

777 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