Forum Moderators: open

Message Too Old, No Replies

Automatic sending of form data

Automatically submit form

         

Adam5000

7:08 pm on Sep 13, 2010 (gmt 0)

10+ Year Member



Greetings all

I'm trying to get my website online and one part involves sending data to a server via a form.

No direct input to the form is required but the information must be sent each time the server is contacted.

I've got it working with a submit button and the code is below. I've simplified it a bit to make it easier for me to explain.

<html>

<head>

<title>Form Page</title>

</head>



<body>

<FORM method='post' action='website server address'>

<INPUT type='hidden' name='x_login' value='loginID'>

<input type='submit' value='Click here to send'>

</form>

</body>

</html>

And what I'd like to do is do away with the "Click here to send" button and have the input value automatically sent when the page is called.

Or in other words there would be two pages involved. Page two would contain the form, and page one would contain a link to it. And when a viewer clicks on the link on page one, page two would be called and the data on page two would be automatically sent without the need of a submit button on page two.

Right now I'm thinking something like using the onLoad command in the body tag but I don't know how it would work.

Help!

Fotiman

8:38 pm on Sep 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Add this script right before the closing </body> tag:

<script type="text/javascript">
document.forms[0].submit();
</script>

Adam5000

7:06 pm on Sep 14, 2010 (gmt 0)

10+ Year Member



That's great Fotiman. This works just fine.

Excuse me while I put my sunglasses on. It's so bright in here it hurts my eyes (smile).