dongpo1216
2015-09-30 12:39
浏览 49
已采纳

是否可以使用PHP表单传递html元素属性?

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.

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

But is it possible with a normal post submit form?

Thanks to all

图片转代码服务由CSDN问答提供 功能建议

我想知道我是否可以发送html元素属性(如 id ,< 代码>类 title ),带有经典的 post form ,并将它们保存在db中。

我知道这个 可以使用 AJAX ,使用javascript保存变量中的值,然后使用 $ .posd $ .ajax <将它们发送到PHP文件 / p>

但是可以使用正常的帖子提交表单吗?

感谢所有

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doujianwei8217 2015-09-30 12:46
    已采纳

    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.

    The following might be an alternative to your proposed $.post-function: you can adjust a form and then submit it using javascript. So, apart from the two JQuery-functions you mention, there is also a form.submit() method. You will have to manipulate the value- and name-attribute of the form-elements and then use .submit() to send those to the server.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • duanheye7423 2015-09-30 12:47

    This is not possible, only names and values are posted.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题