提交< p>的值提交html表单时的元素 [英] Submit the value of a <p> element when an html form is submitted

查看:285
本文介绍了提交< p>的值提交html表单时的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:<p class = "foo">Text</p>

我也有一种形式:<form action = "XXX.php" method = post></form>

但是,提交<p>的值时如何获取它,因为<p>元素可以更改.

However, how can I get the value of the <p> when I submit it, as the <p> element can be changed.

所以我的意思是当用户提交表单时能够发布<p>的值,并能够通过$_POST['foo'];

So what I mean is to be able to post the value of the <p> when the user submits the form, and to be able to access it from that php file with: $_POST['foo'];

谢谢,我试图尽可能清楚一些.

Thanks, I have tried to be as clear as possible.

推荐答案

我认为最好的选择是使它成为启用了只读功能的输入,并使其样式类似于<p>.最好尝试使用JavaScript将其添加到POST参数中.

I think your best bet is to make it an input with readonly enabled, and style to to look like a <p>. It's better then trying to add it to the POST parameters with JavaScript.

这是一个简单的示例 .我敢打赌,仍然可以通过一些额外的CSS改进来改进它,请尝试一下.

Here's a quick example. I bet it could still be improved with a few extra CSS quirks, experiment a bit.

这篇关于提交&lt; p&gt;的值提交html表单时的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆