Jump to content

run form on page load


searls03

Recommended Posts

It can be easily done. Just the action of the form should be another page, or it will just run in a loop (load page, submit, load page, submit).

 

HTML

<form method="post" id="myForm" action="someotherpage.php">
<input type="text" name="name" value="Value" />
    <button type="submit">Submit</button>
</form>

 

Javascript (inside document's <head>)

window.onload = function() {
document.getElementById('myForm').submit();	
}

 

I can't recommend something like this, as most surely there is a better solution to your problem (which I don't know), but if you wanna use it, there you go.

Link to comment
Share on other sites

ok, so I have a message board type thing that submits a form that will set read1 to equal 1, which means it has been read which will set the sender to be not bold.  I want the links to be links, not buttons that look like links for the alignment then gets all off.  does this make sense.  I want the page that has the message to have a form that submits this info on page load to read.php which is what sets read1 to equal 1

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.