Form Submission in Python Without Name Attribute

大城市里の小女人 提交于 2019-12-06 08:33:21

According to the W3 standard, for an input field to be submitted, it must have a name attribute. A quick test on Firefox 3 and Safari 3.2 shows that an input field that is missing the name attribute but has an id attribute is not submitted.

With that said, if you have a form that you want to submit, and some of its fields have id but not name attributes, using the id attribute instead seems like the only available option. It could be that other browsers use the id attribute, or perhaps there is some JavaScript code that handles the submission event instead of letting the browser do it.

An input tag without a name won't be submitted as a form parameter.

For example, create an HTML page containing just this:

<form>
    <input type="text" name="one" value="foo"/>
    <input type="text" value="bar"/>
    <input type="submit"/>
</form>

You can see that the second text field is missing a name attribute. If you click "Submit," the page will refresh with the query string:

test.html?one=foo

A good strategy for this would be to look at a live POST request sent by your browser and start by emulating that. Use a tool like the FireBug extension for Firefox to see the POST request and parameters sent by your browser. There might be parameters in there that you didn't notice before -- possibly because they were hidden form elements or they were created/set by JavaScript.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!