Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cause a form to be submitted automatically on page load in JavaScript?

Tags:

javascript

This may have an obvious answer, but I am very new to js so I have no idea how to do this. I would like a form on a page to be submitted automatically when that page is loaded without requiring any user action like pressing a button. How to do this?

like image 972
Toney Avatar asked Jul 17 '10 20:07

Toney


1 Answers

<form id=lol action="file.php"></form>
<script>document.getElementById('lol').submit();</script>
like image 67
meder omuraliev Avatar answered Nov 04 '22 09:11

meder omuraliev