Tabatha M Tabatha M - 1 year ago 229
Javascript Question

HTML button onload submit

I have a button example below

<button id="startrunning">go</button>

There is no form or anything I'm using on the same page java script to detect it's click. It will work like I want it to when I click it. I want to see when the page is loaded it will automatically submit it's self is there a way?

Thank you

Answer Source


<script type="text/javascript">
    function submit()
        document.getElementById("startrunning").click(); // Simulates button click
        document.submitForm.submit(); // Submits the form without the button

<body onload="submit()">
    <form id="submitForm">
        <button id="startrunning">go</button>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download