Jump to content

Post data to form as initial value


liamloveslearning

Recommended Posts

Hi all,

 

Bit of an amateur question but, I have a button on my page that when clicked I want it to takr the user to a page and auto fill the field values depending on what the page was, anybody know of any tutorials or what this method is called?

 

Would i give the button an ID and retrieve the data via a GET function?

Link to comment
Share on other sites

I have always used php on the next page to populate fields from a previous form.  here is an example.

 

first a simple form

<form name="form1" action="foo.php"  method="POST">
<input type="text" name="value1" value="this is a test" />
<input type="submit" value="submit" />
</form>

then the script which is called by the form action.

 

<form name="whatever"  action="" method="POST">
Input type="text" name="whatever"  value = "<?php echo $_POST[value1]; ?>" />
</form>

 

Notice in the form the beginning and end of PHP.  This is how you pull the post value into the field on the next page.

 

keep in mind you can also put hidden fields on the form of the first page.

 

hope this helps

 

Link to comment
Share on other sites

you would likely be able to do it with javaScript. unforunetly, javascript is one of my weak points.  If you have control of the server however, you can easily install apache, mysql and PHP.  in fact you can have it up and running in under 20 minutes.  I recommend Xampp it is available for windows with a self installer, and is available for linux and even macs.  http://www.apachefriends.org/en/xampp.html

 

I wish I could be of more help, but once again I am not good with javascript.

 

cheers

Link to comment
Share on other sites

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.