将数据从html页面插入到php表单中,如同自动填充值一样

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.