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

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?