?
Solved

Auto Submit of a Form !!! Help

Posted on 2003-11-05
16
Medium Priority
?
218 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

770 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