简体   繁体   中英

Inserting data from an html page to php form as in auto-filling the value

So here is the problem I have a page with 8 of these html boxes. My company wants the #stk ###### to auto fill the form field "stock" when "make an offer" is selected. I did get it to work but the code is very Jerry rigged the code is below the image. I'm just looking for a simpler and none Jerry rigged way to do this.


`<p>3.  <label for="stockNum">* Stock Item Number</label><br>
    <input name="stockNum" type="text" value="<?php
$stock1 =$_POST['stockNum1'];
$stock2 = $_POST['stockNum2'];
print "$stock1";
print "$stock2";
?>
">
`

If this is on a public web site you've got a bunch of problems with that approach, you would want to first filter the $_POST['stockNum1'] variables so nobody tries something shady by inserting javascript: or something else naughty in to your site.

About your specific problem, auto-filling in forms is generally done with Javascript hardcoded or a Javascript library like jQuery which would allow you to just fill in the forms without having to post the data first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM