HTML中的选择顺序选择多个? [英] Order of selection in html select multiple?

查看:51
本文介绍了HTML中的选择顺序选择多个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标记插件,可以以两种形式维护它对标记的选择.一个是内部数组.另一个方法是通过html select,其中只包含所有选中的标签,如果插件是表单的一部分,则允许标签插件像普通元素一样工作.

I have a tagging plugin which maintains it's selection of tags in two forms. One is an internal array. The other is by having an html select which only contains the tags with all selected which allows the tagging plugin to act like a normal element if the plugin is part of a form.

已要求我实施重新排序.我知道如何做到这一点,并调整阵列.对于不同的浏览器如何处理订单,选择令我有些困惑.

I have been asked to implement re-ordering. I know how to do this and adjust the array. The select has me a bit puzzled as to how different browsers handle the order.

所选项目以什么顺序作为表单的一部分提交?按照选择的顺序?按字母顺序/数字按值排列?还是只是从上到下选择项目?

In what order are the selected items submitted as part of the form? In the order they are selected? Alphabetically/numerically by value? Or simply top to bottom with the selected items?

推荐答案

根据HTML规范,表单值将按照它们在文档中出现的顺序提交:

According to the HTML spec, the form values are to be submitted in the order they appear in the document:

  • application/x-www-form-urlencoded(GET或POST):控件名称/值以它们在文档中出现的顺序列出."
  • multipart/form-data(POST):零件以相应的控件出现在文档流中的顺序发送到处理代理."

请参见 http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 了解更多详情.

但是,仅是规范说明的内容,并不意味着浏览器实际执行此操作.浏览器因不遵守w3c规范而臭名昭著.在单独的< input type ="hidden"> 元素中跟踪订单可能更安全.

However, just because that's what the spec says doesn't mean that's what browsers actually do. Browsers are notorious for not following the w3c specs. It's probably safer for you to track the order in a separate <input type="hidden"> element.

这篇关于HTML中的选择顺序选择多个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆