简体   繁体   English

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

[英]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. 所以这是问题所在,我有一个包含8个这些html框的页面。 My company wants the #stk ###### to auto fill the form field "stock" when "make an offer" is selected. 我的公司希望#stk ######在选择“提供要约”时自动填写表单字段“ stock”。 I did get it to work but the code is very Jerry rigged the code is below the image. 我确实可以正常工作,但是代码非常杰里(Jerry)操纵,代码在图像下方。 I'm just looking for a simpler and none Jerry rigged way to do this. 我只是在寻找一种更简单且没有Jerry操纵方式的方法。


`<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. 如果在公共网站上使用该方法会遇到很多问题,则需要首先过滤$_POST['stockNum1']变量,以便没人通过插入javascript:尝试某些可疑的东西javascript:您的网站。

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. 关于您的特定问题,通常使用硬编码的Javascript或jQuery之类的Javascript库来完成表单的自动填充,这使您可以填写表单而不必先发布数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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