searls03 Posted April 25, 2011 Share Posted April 25, 2011 don't have a code for this or anything.....but how do I make a form run on page load.............like a link goes to a form that runs on page load.......does this make sense? Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 26, 2011 Share Posted April 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 Will this go to another page? I need it on same page. Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 26, 2011 Share Posted April 26, 2011 The action="someotherpage.php" attribute will make the form submit on another page and in this case it makes totally sense. I told you, you will run through a loop if you submit it in the same page. Quote Link to comment Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 yeah, I know you said that, but I am not the best with loops, but I will try. thanks Quote Link to comment Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 is there a way to do this without a submit button, like a hidden field that has id and name of submit? Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 26, 2011 Share Posted April 26, 2011 Would be better if you tell what to you want to achieve. What's the scenario? Most probably there is another way. Quote Link to comment Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 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 Quote Link to comment Share on other sites More sharing options...
searls03 Posted April 28, 2011 Author Share Posted April 28, 2011 any thing? Quote Link to comment Share on other sites More sharing options...
matthew9090 Posted May 16, 2011 Share Posted May 16, 2011 this might work <form method="post" id="myForm" action="someotherpage.php"> <input type="text" name="name" value="Value" /> <button type="submit" onload="this.form.submit()">Submit</button> </form> Quote Link to comment Share on other sites More sharing options...
VZdemon Posted May 17, 2011 Share Posted May 17, 2011 you can do it in plane html like so: <body onload="alet('Page loaded')"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.