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.

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

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.