简体   繁体   English

是否可以通过PHP表单传递html元素属性?

[英]Is it possible passing html elements attributes with a PHP form?

I would like to know if I can send html elements attributes (like id , class or title ) with a classic post form and save them in a db. 我想知道是否可以使用经典的post form发送html元素属性(例如idclasstitle )并将其保存在db中。

I know this is possible with AJAX , saving the values in variables with javascript and then sending them to a PHP file with $.post or $.ajax 我知道这可以通过AJAX ,使用javascript将值保存在变量中,然后使用$.post$.ajax将其发送到PHP文件中

But is it possible with a normal post submit form? 但是,使用普通的帖子提交表格可以吗?

Thanks to all 谢谢大家

This is not possible. 这是不可能的。 Only the value- and the name-attribute are sent to the server when you use a classic submit. 使用经典提交时,仅将值和名称属性发送到服务器。 There is no way to get more attributes then these two. 没有比这两个更多的属性。 So, you are forced to use javascript. 因此,您不得不使用javascript。

The following might be an alternative to your proposed $.post-function: you can adjust a form and then submit it using javascript. 以下可能是您建议的$ .post-function的替代方法:您可以调整表单,然后使用javascript提交。 So, apart from the two JQuery-functions you mention, there is also a form.submit() method. 因此,除了您提到的两个JQuery函数之外,还有一个form.submit()方法。 You will have to manipulate the value- and name-attribute of the form-elements and then use .submit() to send those to the server. 您将必须操纵表单元素的值和名称属性,然后使用.submit()将它们发送到服务器。

这是不可能的,仅会发布名称和值。

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

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