Fill HTML Form Fields With JSON Object -


i have basic html form i've created locally , form, same one, on separate local site.

i wondering if there way fill out first html form , automatically fill out second form same data.

i have looked possibly packaging form data json object can't seem find guidance how it.

<!doctype html> <html lang="en">  <head>     <link rel="stylesheet" type="text/css" href="main.css">     <title>form test</title> </head>  <body>     <center>         <h1>form test</h1></center>     <div class="navigation">         <nav>             <a href="secondform.html">second form submission</a>         </nav>     </div>      <p>upon clicking submit button, populated fields should send field data second form emailed someone.</p>  </body> <div id="message"> </div> <form name="form_simple" id="form-simple" action="c:/xampp/htdocs/formsubmit/formsubmit.php" method="post" target="_blank">     name:     <br>     <input type="text" name="name" value="">     <br> email:     <br>     <input type="email" name="email" value="">     <br> university:     <br>     <input type="text" name="university" value="">     <br> year in school:     <br>     <input type="text" name="year" value="">     <br> grad date:     <br>     <input type="date" name="graddate" value="">     <br>     <br>     <input type="submit" value="submit"> </form>  </html> 

since you're using php, there's no need monkey-about json encoding data. when hit submit button, formsubmit.php page requested.

in it, can of data form held. can use populate fields of next form.

i imagine you're not yet familiar $_post , $_get arrays available each , every php script. since method of above form post, can grab submitted values $_post array.

that say, array contain elements in array indexed name of original form inputs. in case, these found in $_post['name'], $_post['email'], $_post['university'], $_post['year'] , $_post['graddate'].

now's time mention shouldn't include full local path of script in action attribute of form. refer relative web-server's root folder. in case, c:/xampp/htdocs - equates address of localhost/ in browser. so, should change action /formsubmit/formsubmit.php or formsubmit.php if html shown above , php file both exist in same folder.

something else may find of use var_dump function. if place var_dump($_post); in formsubmit.php file, can see entered values straight there on screen - helpful tool debugging, allowing check think sent via post in fact sent, , named , structured expecting. can trivially populate fields on target form retrieving , echoing passed data.

an example perform no error-checking, has no styling, inert , populate 2 fields may this:

formsubmit.php

<?php   $name = $_post['name'];   $email = $_post['email']; ?> <html> <body>   <form>     <input type='text' name='nameinput' value='<?php echo $name; ?>' />     <input type='email' name='emailinput' value='<?php echo $email; ?>' />   </form> </body> </html> 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -