处理大量的HTML复选框 [英] Dealing with large numbers of HTML checkboxes

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

问题描述

我正在处理一种动态表格,该表格可能为用户提供数组(category [])中未指定数量的复选框.

I am dealing with a dynamic form that can potentially provide the user with an unspecified number of checkboxes in an array (category[]).

这会导致一些问题.

问题#1 :达到浏览器和/或服务器允许的最大POST变量数.这可以通过使用一些脚本并将数组实际发布为单个逗号分隔的值来解决.

Issue #1: Hitting the maximum number of POST variables that the browser and/or server allows. This can be solved by using a bit of script and actually posting the array in a single comma separated value.

问题2 :浏览器变得非常缓慢和/或崩溃.一位用户有超过5000个代表类别的复选框,这会导致Chrome出现错误,Firefox运行缓慢,我还不敢在IE中尝试!

Issue #2: Browsers getting very slow and / or crashing. One user has over 5000 checkboxes representing categories, which causes Chrome to bug out, Firefox to go very slowly and I dare not try it in IE yet!

我希望就如何解决第二个问题提出一些建议或想法!

I would love some suggestions or ideas on how to solve the second problem!

此致

乔尔

推荐答案

我发现滞后/缓慢的原因是由于jquery循环在所有输入上执行each()以确定是否已存在任何字段改变了.显然,jQuery不喜欢遍历这么多元素.

I discovered that the cause of the lag / slowness was due to a jquery loop which was doing an each() on all inputs to determine if any fields have been changed. Obviously jQuery doesn't like looping through that many elements.

我阻止循环进入复选框列表,并且不再慢了.

I stopped the loop from hitting the checkbox list and it's no longer slow.

能够一次抓取复选框列表中的值的数组,而不用一遍又一遍地遍历它们,将是一个很好的选择!

It would be nice to be able to grab an array of values of the checkbox list in one hit rather than having to loop through them all!

这篇关于处理大量的HTML复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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