Home  >  Article  >  Backend Development  >  php如何往html表单里添加一些字段?

php如何往html表单里添加一些字段?

WBOY
WBOYOriginal
2016-06-06 20:10:431500browse

由于一些特殊需求只能用php(在php文件中)把一些数据放进html表单的隐藏字段。

如何做?
谢谢

回复内容:

由于一些特殊需求只能用php(在php文件中)把一些数据放进html表单的隐藏字段。

如何做?
谢谢

只在php中修改,也就是说不能修改html模板咯,那就有个问题,你的值放到html的哪个位置。
所以html或者js是要修改的呀。
或者你可以采用ajax异步加载去实现咯。
单单是只修改php,那你只能将html代码包含在php文件中啦

用个hidden,应该就可以

拼接要隐藏的html的字段呀,加type="hidden"

<code><input type="hidden" value="<?php echo $someData; ?>"></code>

php文件是以html代码为主体代码

<code><input type="hidden" name="xx" value="<?php echo $xx ?>"></code>

纯php代码的

<code><?php echo '<input type="hidden" name="xx" value="'.$xx.'"/>';
?></code>

拼接要隐藏的html的字段呀,加type="hidden"

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn