Javascript Submit does not include Submit Button Value

前端 未结 7 2180
野性不改
野性不改 2020-12-01 14:01

Ok, this is less of a question than it is just for my information (because I can think of about 4 different work arounds that will make it work. But I have a form (nothing

7条回答
  •  臣服心动
    2020-12-01 14:21

    Yes, that is the correct behavior of HTMLFormElement.submit()

    The reason your submit button value isn't sent is because HTML forms are designed so that they send the value of the submit button that was clicked (or otherwise activated). This allows for multiple submit buttons per form, such as a scenario where you'd want both "Preview" and a "Save" action.

    Since you are programmatically submitting the form, there is no explicit user action on an individual submit button so nothing is sent.

提交回复
热议问题